Skip to content

Commit c44556f

Browse files
committed
Merge branch 'v2.0.x'
Conflicts: INSTALL README.rst lib/matplotlib/__init__.py lib/matplotlib/axes/_axes.py lib/matplotlib/tests/baseline_images/test_patheffects/collection.pdf lib/matplotlib/tests/baseline_images/test_patheffects/collection.png lib/matplotlib/tests/baseline_images/test_patheffects/collection.svg lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.svg lib/matplotlib/tests/test_axes.py lib/matplotlib/tests/test_coding_standards.py lib/matplotlib/tests/test_patheffects.py lib/matplotlib/tests/test_ticker.py
2 parents b156bf0 + 4d4f8d3 commit c44556f

32 files changed

+2013
-769
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
.. |PyPi| image:: https://badge.fury.io/py/matplotlib.svg
1414
.. _PyPi: https://badge.fury.io/py/matplotlib
1515

16-
.. |Gitter| image:: https://img.shields.io/gitter/room/nwjs/nw.js.svg
16+
.. |Gitter| image:: https://img.shields.io/gitter/room/nwjs/nw.js.svg
1717
:target: https://gitter.im/matplotlib/matplotlib?utm_source=share-link&utm_medium=link&utm_campaign=share-link
1818

1919
.. |Depsy| image:: http://depsy.org/api/package/pypi/matplotlib/badge.svg
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Do not clip line width when scaling dashes
2+
``````````````````````````````````````````
3+
4+
The algorithm to scale dashes was changed to no longer clip the
5+
scaling factor: the dash patterns now continue to shrink at thin line widths.
6+
If the line width is smaller than the effective pixel size, this may result in
7+
dashed lines turning into solid gray-ish lines. This also required slightly
8+
tweaking the default patterns for '--', ':', and '.-' so that with the default
9+
line width the final patterns would not change.
10+
11+
There is no way to restore the old behavior.

doc/users/gridspec.rst

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,47 @@
55
Customizing Location of Subplot Using GridSpec
66
**********************************************
77

8-
``GridSpec``
8+
:class:`~matplotlib.gridspec.GridSpec`
99
specifies the geometry of the grid that a subplot will be
1010
placed. The number of rows and number of columns of the grid
1111
need to be set. Optionally, the subplot layout parameters
1212
(e.g., left, right, etc.) can be tuned.
1313

14-
``SubplotSpec``
14+
:class:`~matplotlib.gridspec.SubplotSpec`
1515
specifies the location of the subplot in the given *GridSpec*.
1616

17-
``subplot2grid``
18-
a helper function that is similar to "pyplot.subplot" but uses
19-
0-based indexing and let subplot to occupy multiple cells.
17+
:func:`~matplotlib.pyplot.subplot2grid`
18+
a helper function that is similar to :func:`~matplotlib.pyplot.subplot`
19+
but uses 0-based indexing and let subplot to occupy multiple cells.
2020

2121

2222
Basic Example of using subplot2grid
2323
===================================
2424

25-
To use subplot2grid, you provide geometry of the grid and the location
26-
of the subplot in the grid. For a simple single-cell subplot::
25+
To use :func:`~matplotlib.pyplot.subplot2grid`, you provide geometry of
26+
the grid and the location of the subplot in the grid. For a simple
27+
single-cell subplot::
2728

28-
ax = plt.subplot2grid((2,2),(0, 0))
29+
ax = plt.subplot2grid((2, 2), (0, 0))
2930

3031
is identical to ::
3132

32-
ax = plt.subplot(2,2,1)
33+
ax = plt.subplot(2, 2, 1)
3334

34-
Note that, unlike matplotlib's subplot, the index starts from 0 in gridspec.
35+
Note that, unlike Matplotlib's subplot, the index starts from 0 in GridSpec.
3536

3637
To create a subplot that spans multiple cells, ::
3738

38-
ax2 = plt.subplot2grid((3,3), (1, 0), colspan=2)
39-
ax3 = plt.subplot2grid((3,3), (1, 2), rowspan=2)
39+
ax2 = plt.subplot2grid((3, 3), (1, 0), colspan=2)
40+
ax3 = plt.subplot2grid((3, 3), (1, 2), rowspan=2)
4041

4142
For example, the following commands ::
4243

43-
ax1 = plt.subplot2grid((3,3), (0,0), colspan=3)
44-
ax2 = plt.subplot2grid((3,3), (1,0), colspan=2)
45-
ax3 = plt.subplot2grid((3,3), (1, 2), rowspan=2)
46-
ax4 = plt.subplot2grid((3,3), (2, 0))
47-
ax5 = plt.subplot2grid((3,3), (2, 1))
44+
ax1 = plt.subplot2grid((3, 3), (0, 0), colspan=3)
45+
ax2 = plt.subplot2grid((3, 3), (1, 0), colspan=2)
46+
ax3 = plt.subplot2grid((3, 3), (1, 2), rowspan=2)
47+
ax4 = plt.subplot2grid((3, 3), (2, 0))
48+
ax5 = plt.subplot2grid((3, 3), (2, 1))
4849

4950
creates
5051

@@ -54,47 +55,48 @@ creates
5455
GridSpec and SubplotSpec
5556
========================
5657

57-
You can create GridSpec explicitly and use them to create a Subplot.
58+
You can create :class:`~matplotlib.gridspec.GridSpec` explicitly and use
59+
them to create a subplot.
5860

5961
For example, ::
6062

61-
ax = plt.subplot2grid((2,2),(0, 0))
63+
ax = plt.subplot2grid((2, 2), (0, 0))
6264

6365
is equal to ::
6466

6567
import matplotlib.gridspec as gridspec
6668
gs = gridspec.GridSpec(2, 2)
6769
ax = plt.subplot(gs[0, 0])
6870

69-
A gridspec instance provides array-like (2d or 1d) indexing that
70-
returns the SubplotSpec instance. For, SubplotSpec that spans multiple
71+
A GridSpec instance provides array-like (2d or 1d) indexing that
72+
returns the SubplotSpec instance. For a SubplotSpec that spans multiple
7173
cells, use slice. ::
7274

73-
ax2 = plt.subplot(gs[1,:-1])
75+
ax2 = plt.subplot(gs[1, :-1])
7476
ax3 = plt.subplot(gs[1:, -1])
7577

7678
The above example becomes ::
7779

7880
gs = gridspec.GridSpec(3, 3)
7981
ax1 = plt.subplot(gs[0, :])
80-
ax2 = plt.subplot(gs[1,:-1])
82+
ax2 = plt.subplot(gs[1, :-1])
8183
ax3 = plt.subplot(gs[1:, -1])
82-
ax4 = plt.subplot(gs[-1,0])
83-
ax5 = plt.subplot(gs[-1,-2])
84+
ax4 = plt.subplot(gs[-1, 0])
85+
ax5 = plt.subplot(gs[-1, -2])
8486

8587
.. plot:: users/plotting/examples/demo_gridspec02.py
8688

8789
Adjust GridSpec layout
8890
======================
8991

9092
When a GridSpec is explicitly used, you can adjust the layout
91-
parameters of subplots that are created from the gridspec. ::
93+
parameters of subplots that are created from the GridSpec. ::
9294

9395
gs1 = gridspec.GridSpec(3, 3)
9496
gs1.update(left=0.05, right=0.48, wspace=0.05)
9597

96-
This is similar to *subplots_adjust*, but it only affects the subplots
97-
that are created from the given GridSpec.
98+
This is similar to :func:`~matplotlib.pyplot.subplots_adjust`, but it only
99+
affects the subplots that are created from the given GridSpec.
98100

99101
The code below ::
100102

@@ -117,8 +119,9 @@ creates
117119
GridSpec using SubplotSpec
118120
==========================
119121

120-
You can create GridSpec from the SubplotSpec, in which case its layout
121-
parameters are set to that of the location of the given SubplotSpec. ::
122+
You can create GridSpec from the :class:`~matplotlib.gridspec.SubplotSpec`,
123+
in which case its layout parameters are set to that of the location of
124+
the given SubplotSpec. ::
122125

123126
gs0 = gridspec.GridSpec(1, 2)
124127

@@ -132,8 +135,8 @@ parameters are set to that of the location of the given SubplotSpec. ::
132135
A Complex Nested GridSpec using SubplotSpec
133136
===========================================
134137

135-
Here's a more sophisticated example of nested gridspec where we put
136-
a box around each cell of the outer 4x4 grid, by hiding appropriate
138+
Here's a more sophisticated example of nested GridSpec where we put
139+
a box around each cell of the outer 4x4 grid, by hiding appropriate
137140
spines in each of the inner 3x3 grids.
138141

139142
.. plot:: users/plotting/examples/demo_gridspec06.py
@@ -147,8 +150,8 @@ relative heights and widths of rows and columns. Note that absolute
147150
values are meaningless, only their relative ratios matter. ::
148151

149152
gs = gridspec.GridSpec(2, 2,
150-
width_ratios=[1,2],
151-
height_ratios=[4,1]
153+
width_ratios=[1, 2],
154+
height_ratios=[4, 1]
152155
)
153156

154157
ax1 = plt.subplot(gs[0])

examples/pylab_examples/demo_bboximage.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
a = np.linspace(0, 1, 256).reshape(1, -1)
2626
a = np.vstack((a, a))
2727

28-
maps = sorted(m for m in plt.cm.cmap_d if not m.endswith("_r"))
29-
maps.remove('spectral') # Deprecated.
30-
#nmaps = len(maps) + 1
28+
maps = sorted(
29+
m for m in plt.cm.cmap_d
30+
if not m.endswith("_r") and # Skip reversed colormaps.
31+
not m.startswith(('spectral', 'Vega')) # Skip deprecated colormaps.
32+
)
3133

3234
#fig.subplots_adjust(top=0.99, bottom=0.01, left=0.2, right=0.99)
3335

lib/matplotlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ def _get_config_or_cache_dir(xdg_base):
634634
h = get_home()
635635
if h is not None:
636636
p = os.path.join(h, '.matplotlib')
637-
if sys.platform.startswith('linux') or sys.platform.startswith('freebsd'):
637+
if sys.platform.startswith(('linux', 'freebsd')):
638638
p = None
639639
if xdg_base is not None:
640640
p = os.path.join(xdg_base, 'matplotlib')

lib/matplotlib/afm.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@
5757
def _to_int(x):
5858
return int(float(x))
5959

60+
6061
_to_float = float
61-
if six.PY3:
62-
def _to_str(x):
63-
return x.decode('utf8')
64-
else:
65-
_to_str = str
62+
63+
64+
def _to_str(x):
65+
return x.decode('utf8')
6666

6767

6868
def _to_list_of_ints(s):

lib/matplotlib/backends/backend_qt5.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,16 @@ def leaveEvent(self, event):
278278
FigureCanvasBase.leave_notify_event(self, guiEvent=event)
279279

280280
def mouseEventCoords(self, pos):
281-
x = pos.x() * self._dpi_ratio
281+
"""
282+
Calculate mouse coordinates in logical pixels.
283+
284+
Qt5 and Matplotlib use logical pixels, but the figure is scaled to
285+
physical pixels for rendering. Also, the origin is different and needs
286+
to be corrected.
287+
"""
288+
x = pos.x()
282289
# flip y so y=0 is bottom of canvas
283-
y = self.figure.bbox.height - pos.y() * self._dpi_ratio
290+
y = self.figure.bbox.height / self._dpi_ratio - pos.y()
284291
return x, y
285292

286293
def mousePressEvent(self, event):

0 commit comments

Comments
 (0)