8000 Merge remote-tracking branch 'matplotlib/v2.0.x' · matplotlib/matplotlib@963faed · GitHub
[go: up one dir, main page]

Skip to content

Commit 963faed

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.0.x'
Conflicts: doc/users/pyplot_tutorial.rst examples/mplot3d/bars3d_demo.py examples/mplot3d/pathpatch3d.py examples/mplot3d/polys3d_demo.py examples/units/artist_tests.py - kept master version examples/units/radian_demo.py - merged changes examples/user_interfaces/svg_tooltip_sgskip.py - white space lib/matplotlib/axes/_base.py - white space lib/matplotlib/tests/test_animation.py - kept master version lib/matplotlib/tests/test_axes.py - kept master version lib/matplotlib/tests/test_figure.py - kept new tests + fixed decorators lib/matplotlib/tests/test_legend.py - kept new tests + fixed decorators
2 parents cffbf53 + 4308d39 commit 963faed

File tree

16 files changed

+1697
-51
lines changed

16 files changed

+1697
-51
lines changed

doc/users/github_stats.rst

Lines changed: 555 additions & 10 deletions
Large diffs are not rendered by default.

examples/units/radian_demo.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
Radian ticks
44
============
55
6-
Plot using radian units.
6+
Plot with radians from the basic_units mockup example package.
7+
8+
9+
This example shows how the unit class can determine the tick locating,
10+
formatting and axis labeling.
711
812
.. only:: builder_html
913

examples/user_interfaces/svg_tooltip_sgskip.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@
4040

4141
for i, (item, label) in enumerate(zip(shapes, labels)):
4242
patch = ax.add_patch(item)
43-
annotate = ax.annotate(labels[i], xy=item.get_xy(), xytext=(0, 0),
44-
textcoords='offset points', color='w', ha='center',
45-
fontsize=8, bbox=dict(boxstyle='round, pad=.5', fc=(.1, .1, .1, .92),
46-
ec=(1., 1., 1.), lw=1, zorder=1))
43+
annotate = ax.annotate(labels[i], xy=item.get_xy(), xytext=(0, 0),
44+
textcoords='offset points', color='w', ha='center',
45+
fontsize=8, bbox=dict(boxstyle='round, pad=.5',
46+
fc=(.1, .1, .1, .92),
47+
ec=(1., 1., 1.), lw=1,
48+
zorder=1))
4749

4850
ax.add_patch(patch)
4951
patch.set_gid('mypatch_{:03d}'.format(i))

extern/agg24-svn/include/agg_rendering_buffer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace agg
6262
m_stride = stride;
6363
if(stride < 0)
6464
{
65-
m_start = m_buf - int(height - 1) * stride;
65+
m_start = m_buf - (AGG_INT64)(height - 1) * stride;
6666
}
6767
}
6868

@@ -80,10 +80,10 @@ namespace agg
8080
//--------------------------------------------------------------------
8181
AGG_INLINE T* row_ptr(int, int y, unsigned)
8282
{
83-
return m_start + y * m_stride;
83+
return m_start + y * (AGG_INT64)m_stride;
8484
}
85-
AGG_INLINE T* row_ptr(int y) { return m_start + y * m_stride; }
86-
AGG_INLINE const T* row_ptr(int y) const { return m_start + y * m_stride; }
85+
AGG_INLINE T* row_ptr(int y) { return m_start + y * (AGG_INT64)m_stride; }
86+
AGG_INLINE const T* row_ptr(int y) const { return m_start + y * (AGG_INT64)m_stride; }
8787
AGG_INLINE row_data row (int y) const
8888
{
8989
return row_data(0, m_width-1, row_ptr(y));
@@ -181,7 +181,7 @@ namespace agg
181181

182182
if(stride < 0)
183183
{
184-
row_ptr = m_buf - int(height - 1) * stride;
184+
row_ptr = m_buf - (AGG_INT64)(height - 1) * stride;
185185
}
186186

187187
T** rows = &m_rows[0];

lib/matplotlib/axes/_base.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,10 +2274,14 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval,
22742274
# ignore non-finite data limits if good limits exist
22752275
finite_dl = [d for d in dl if np.isfinite(d).all()]
22762276
if len(finite_dl):
2277-
# if finite limits exist for atleast one axis (and the other is infinite), restore the
2278-
# finite limits
2279-
x_finite = [d for d in dl if (np.isfinite(d.intervalx).all() and (d not in finite_dl))]
2280-
y_finite = [d for d in dl if (np.isfinite(d.intervaly).all() and (d not in finite_dl))]
2277+
# if finite limits exist for atleast one axis (and the
2278+
# other is infinite), restore the finite limits
2279+
x_finite = [d for d in dl
2280+
if (np.isfinite(d.intervalx).all() and
2281+
(d not in finite_dl))]
2282+
y_finite = [d for d in dl
2283+
if (np.isfinite(d.intervaly).all() and
2284+
(d not in finite_dl))]
22812285

22822286
dl = finite_dl
22832287
dl.extend(x_finite)

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None,
21062106
dpi = rcParams['savefig.dpi']
21072107

21082108
if dpi == 'figure':
2109-
dpi = self.figure.dpi
2109+
dpi = getattr(self.figure, '_original_dpi', self.figure.dpi)
21102110

21112111
if facecolor is None:
21122112
facecolor = rcParams['savefig.facecolor']

lib/matplotlib/backends/backend_qt5.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ def _create_qApp():
148148
qApp = app
149149

150150
if is_pyqt5():
151-
qApp.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
151+
try:
152+
qApp.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
153+
qApp.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
154+
except AttributeError:
155+
pass
152156

153157

154158
class Show(ShowBase):
@@ -158,6 +162,7 @@ def mainloop(self):
158162
global qApp
159163
qApp.exec_()
160164

165+
161166
show = Show()
162167

163168

@@ -267,17 +272,20 @@ def leaveEvent(self, event):
267272
FigureCanvasBase.leave_notify_event(self, guiEvent=event)
268273

269274
def mouseEventCoords(self, pos):
270-
"""
271-
Calculate mouse coordinates in logical pixels.
275+
"""Calculate mouse coordinates in physical pixels
276+
277+
Qt5 use logical pixels, but the figure is scaled to physical
278+
pixels for rendering. Transform to physical pixels so that
279+
all of the down-stream transforms work as expected.
280+
281+
Also, the origin is different and needs to be corrected.
272282
273-
Qt5 and Matplotlib use logical pixels, but the figure is scaled to
274-
physical pixels for rendering. Also, the origin is different and needs
275-
to be corrected.
276283
"""
284+
dpi_ratio = self._dpi_ratio
277285
x = pos.x()
278286
# flip y so y=0 is bottom of canvas
279-
y = self.figure.bbox.height / self._dpi_ratio - pos.y()
280-
return x, y
287+
y = self.figure.bbox.height / dpi_ratio - pos.y()
288+
return x * dpi_ratio, y * dpi_ratio
281289

282290
def mousePressEvent(self, event):
283291
x, y = self.mouseEventCoords(event.pos())
@@ -602,7 +610,10 @@ def __init__(self, canvas, parent, coordinates=True):
602610
def _icon(self, name):
603611
if is_pyqt5():
604612
name = name.replace('.png', '_large.png')
605-
return QtGui.QIcon(os.path.join(self.basedir, name))
613+
pm = QtGui.QPixmap(os.path.join(self.basedir, name))
614+
if hasattr(pm, 'setDevicePixelRatio'):
615+
pm.setDevicePixelRatio(self.canvas._dpi_ratio)
616+
return QtGui.QIcon(pm)
606617

607618
def _init_toolbar(self):
608619
self.basedir = os.path.join(matplotlib.rcParams['datapath'], 'images')
@@ -612,7 +623,7 @@ def _init_toolbar(self):
612623
self.addSeparator()
613624
else:
614625
a = self.addAction(self._icon(image_file + '.png'),
615-
text, getattr(self, callback))
626+
text, getattr(self, callback))
616627
self._actions[callback] = a
617628
if callback in ['zoom', 'pan']:
618629
a.setCheckable(True)
@@ -634,7 +645,7 @@ def _init_toolbar(self):
634645
QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)
635646
self.locLabel.setSizePolicy(
636647
QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
637-
QtWidgets.QSizePolicy.Ignored))
648+
QtWidgets.QSizePolicy.Ignored))
638649
labelAction = self.addWidget(self.locLabel)
639650
labelAction.setVisible(True)
640651

lib/matplotlib/backends/qt_compat.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
# compatible use the env variable.
7777
QT_API = ETS[QT_API_ENV][0]
7878

79+
_fallback_to_qt4 = False
7980
if QT_API is None:
8081
# No ETS environment or incompatible so use rcParams.
8182
if rcParams['backend'] == 'Qt5Agg':
@@ -87,7 +88,7 @@
8788
# bindings is imported, but we still got here because a Qt
8889
# related file was imported. This is allowed, fall back to Qt5
8990
# using which ever binding the rparams ask for.
90-
91+
_fallback_to_qt4 = True
9192
QT_API = rcParams['backend.qt5']
9293

9394
# We will define an appropriate wrapper for the differing versions
@@ -136,9 +137,12 @@
136137
from PyQt5 import QtCore, QtGui, QtWidgets
137138
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
138139
except ImportError:
139-
# fell through, tried PyQt5, failed fall back to PyQt4
140-
QT_API = rcParams['backend.qt4']
141-
QT_RC_MAJOR_VERSION = 4
140+
if _fallback_to_qt4:
141+
# fell through, tried PyQt5, failed fall back to PyQt4
142+
QT_API = rcParams['backend.qt4']
143+
QT_RC_MAJOR_VERSION = 4
144+
else:
145+
raise
142146

143147
# needs to be if so we can re-test the value of QT_API which may
144148
# have been changed in the above if block

lib/matplotlib/figure.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,10 @@ def __init__(self,
324324
if frameon is None:
325325
frameon = rcParams['figure.frameon']
326326

327-
self.dpi_scale_trans = Affine2D()
328-
self.dpi = dpi
329327
self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
328+
self.dpi_scale_trans = Affine2D().scale(dpi, dpi)
329+
# do not use property as it will trigger
330+
self._dpi = dpi
330331
self.bbox = TransformedBbox(self.bbox_inches, self.dpi_scale_trans)
331332

332333
self.frameon = frameon
@@ -415,6 +416,7 @@ def _get_dpi(self):
415416
def _set_dpi(self, dpi):
416417
self._dpi = dpi
417418
self.dpi_scale_trans.clear().scale(dpi, dpi)
419+
self.set_size_inches(*self.get_size_inches())
418420
self.callbacks.process('dpi_changed', self)
419421
dpi = property(_get_dpi, _set_dpi)
420422

@@ -713,13 +715,15 @@ def set_size_inches(self, w, h=None, forward=True):
713715
self.bbox_inches.p1 = w, h
714716

715717
if forward:
716-
ratio = getattr(self.canvas, '_dpi_ratio', 1)
717-
dpival = self.dpi / ratio
718-
canvasw = w * dpival
719-
canvash = h * dpival
720-
manager = getattr(self.canvas, 'manager', None)
721-
if manager is not None:
722-
manager.resize(int(canvasw), int(canvash))
718+
canvas = getattr(self, 'canvas')
719+
if canvas is not None:
720+
ratio = getattr(self.canvas, '_dpi_ratio', 1)
721+
dpival = self.dpi / ratio
722+
canvasw = w * dpival
723+
canvash = h * dpival
724+
manager = getattr(self.canvas, 'manager', None)
725+
if manager is not None:
726+
manager.resize(int(canvasw), int(canvash))
723727
self.stale = True
724728

725729
def get_size_inches(self):

lib/matplotlib/legend_handler.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,8 @@ class HandlerPolyCollection(HandlerBase):
632632
"""
633633
def _update_prop(self, legend_handle, orig_handle):
634634
def first_color(colors):
635+
if colors is None:
636+
return None
635637
colors = mcolors.to_rgba_array(colors)
636638
if len(colors):
637639
return colors[0]
@@ -642,8 +644,12 @@ def get_first(prop_array):
642644
return prop_array[0]
643645
else:
644646
return None
645-
legend_handle.set_edgecolor(first_color(orig_handle.get_edgecolor()))
646-
legend_handle.set_facecolor(first_color(orig_handle.get_facecolor()))
647+
edgecolor = getattr(orig_handle, '_original_edgecolor',
648+
orig_handle.get_edgecolor())
649+
legend_handle.set_edgecolor(first_color(edgecolor))
650+
facecolor = getattr(orig_handle, '_original_facecolor',
651+
orig_handle.get_facecolor())
652+
legend_handle.set_facecolor(first_color(facecolor))
647653
legend_handle.set_fill(orig_handle.get_fill())
648654
legend_handle.set_hatch(orig_handle.get_hatch())
649655
legend_handle.set_linewidth(get_first(orig_handle.get_linewidths()))

lib/matplotlib/patches.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def update_from(self, other):
200200
self._facecolor = other._facecolor
201201
self._fill = other._fill
202202
self._hatch = other._hatch
203+
self._hatch_color = other._hatch_color
203204
# copy the unscaled dash pattern
204205
self._us_dashes = other._us_dashes
205206
self.set_linewidth(other._linewidth) # also sets dash properties
Binary file not shown.
Loading

0 commit comments

Comments
 (0)
0