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

Skip to content

Commit 3612616

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.x'
Conflicts: doc/api/axes_api.rst - whitespace lib/matplotlib/artist.py - git hiccup, conflicting blocks were identical (and no net change) lib/matplotlib/tests/test_colorbar.py - overlapping tests
2 parents 5b1d671 + 83e0dce commit 3612616

File tree

11 files changed

+150
-21
lines changed

11 files changed

+150
-21
lines changed

INSTALL

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,19 @@ Required Dependencies
214214
`cycler <http://matplotlib.org/cycler/>`__ 0.10.0 or later
215215
Composable cycle class used for constructing style-cycles
216216

217-
`functools32`
218-
Required for compatibility if running on versions of Python before
219-
Python 3.2.
217+
`six <https://pypi.python.org/pypi/six>`_
218+
Required for compatibility between python 2 and python 3
219+
220+
221+
Dependencies for python 2
222+
^^^^^^^^^^^^^^^^^^^^^^^^^
223+
224+
`functools32 <https://pypi.python.org/pypi/functools32>`_
225+
Required for compatibility if running on Python 2.7.
226+
227+
`subprocess32 <https://pypi.python.org/pypi/subprocess32/>`_
228+
Optional, unix only. Backport of the subprocess standard library from 3.2+
229+
for Python 2.7. It provides better error messages and timeout support.
220230

221231
Optional GUI framework
222232
^^^^^^^^^^^^^^^^^^^^^^
@@ -278,10 +288,6 @@ Required libraries that ship with matplotlib
278288
`ttconv`
279289
truetype font utility
280290

281-
six 1.9.0
282-
Python 2/3 compatibility library. Do not use this in third-party
283-
code.
284-
285291

286292
.. _build_linux:
287293

doc/_static/contour_frontpage.png

-10.6 KB
Loading

doc/_static/histogram_frontpage.png

26 Bytes
Loading

doc/_static/membrane_frontpage.png

-642 Bytes
Loading

doc/_static/surface3d_frontpage.png

-11 KB
Loading

doc/api/axes_api.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,19 @@ Axis scales
295295

296296

297297

298-
Autoscaling
299-
-----------
298+
Autoscaling and margins
299+
-----------------------
300300

301301
.. autosummary::
302302
:toctree: _as_gen
303303
:nosignatures:
304304

305+
Axes.use_sticky_edges
306+
307+
Axes.margins
308+
Axes.set_xmargin
309+
Axes.set_ymargin
310+
305311
Axes.relim
306312

307313
Axes.autoscale
@@ -317,7 +323,6 @@ Autoscaling
317323
Axes.set_autoscaley_on
318324

319325

320-
321326
Aspect ratio
322327
------------
323328

@@ -361,7 +366,6 @@ Ticks and tick labels
361366

362367
Axes.set_xticklabels
363368
Axes.set_xticks
364-
Axes.set_ymargin
365369
Axes.set_yticklabels
366370
Axes.set_yticks
367371

examples/frontpage/plot_3D.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
====================
3+
Frontpage 3D example
4+
====================
5+
6+
This example reproduces the frontpage 3D example.
7+
8+
"""
9+
from mpl_toolkits.mplot3d import Axes3D
10+
from matplotlib import cbook
11+
from matplotlib import cm
12+
from matplotlib.colors import LightSource
13+
import matplotlib.pyplot as plt
14+
import numpy as np
15+
16+
filename = cbook.get_sample_data('jacksboro_fault_dem.npz', asfileobj=False)
17+
with np.load(filename) as dem:
18+
z = dem['elevation']
19+
nrows, ncols = z.shape
20+
x = np.linspace(dem['xmin'], dem['xmax'], ncols)
21+
y = np.linspace(dem['ymin'], dem['ymax'], nrows)
22+
x, y = np.meshgrid(x, y)
23+
24+
region = np.s_[5:50, 5:50]
25+
x, y, z = x[region], y[region], z[region]
26+
27+
fig, ax = plt.subplots(subplot_kw=dict(projection='3d'), figsize=(1.62, 1.38))
28+
29+
ls = LightSource(270, 45)
30+
# To use a custom hillshading mode, override the built-in shading and pass
31+
# in the rgb colors of the shaded surface calculated from "shade".
32+
rgb = ls.shade(z, cmap=cm.gist_earth, vert_exag=0.1, blend_mode='soft')
33+
surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, facecolors=rgb,
34+
linewidth=0, antialiased=False, shade=False)
35+
ax.set_xticks([])
36+
ax.set_yticks([])
37+
ax.set_zticks([])
38+
fig.savefig("surface3d_frontpage.png")

examples/frontpage/plot_contour.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
=========================
3+
Frontpage contour example
4+
=========================
5+
6+
This example reproduces the frontpage contour example.
7+
"""
8+
9+
import matplotlib.pyplot as plt
10+
import numpy as np
11+
from matplotlib import mlab, cm
12+
13+
extent = (-3, 3, -3, 3)
14+
15+
delta = 0.5
16+
x = np.arange(-3.0, 4.001, delta)
17+
y = np.arange(-4.0, 3.001, delta)
18+
X, Y = np.meshgrid(x, y)
19+
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, -0.5)
20+
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
21+
Z = (Z1 - Z2) * 10
22+
23+
levels = np.linspace(-2.0, 1.601, 40)
24+
norm = cm.colors.Normalize(vmax=abs(Z).max(), vmin=-abs(Z).max())
25+
26+
fig, ax = plt.subplots(figsize=(1.62, 1.38))
27+
cset1 = ax.contourf(
28+
X, Y, Z, levels,
29+
norm=norm)
30+
ax.set_xlim(-3, 3)
31+
ax.set_ylim(-3, 3)
32+
ax.set_xticks([])
33+
ax.set_yticks([])
34+
fig.savefig("contour_frontpage.png")

examples/frontpage/plot_histogram.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
===========================
3+
Frontpage histogram example
4+
===========================
5+
6+
This example reproduces the frontpage histogram example.
7+
"""
8+
9+
import matplotlib.pyplot as plt
10+
import numpy as np
11+
12+
13+
random_state = np.random.RandomState(19680801)
14+
X = random_state.randn(10000)
15+
16+
fig, ax = plt.subplots(figsize=(1.62, 1.38))
17+
ax.hist(X, bins=25, normed=True)
18+
x = np.linspace(-5, 5, 1000)
19+
ax.plot(x, 1 / np.sqrt(2*np.pi) * np.exp(-(x**2)/2), linewidth=4)
20+
ax.set_xticks([])
21+
ax.set_yticks([])
22+
fig.savefig("histogram_frontpage.png")

examples/frontpage/plot_membrane.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
======================
3+
Frontpage plot example
4+
======================
5+
6+
7+
This example reproduces the frontpage simple plot example.
8+
"""
9+
10+
import matplotlib.pyplot as plt
11+
import matplotlib.cbook as cbook
12+
import numpy as np
13+
14+
15+
datafile = cbook.get_sample_data('membrane.dat', asfileobj=False)
16+
x = np.fromfile(datafile, np.float32)
17+
# 0.0005 is the sample interval
18+
19+
fig, ax = plt.subplots(figsize=(1.62, 1.38))
20+
ax.plot(x, linewidth=4)
21+
ax.set_xlim(5000, 6000)
22+
ax.set_ylim(-0.6, 0.1)
23+
ax.set_xticks([])
24+
ax.set_yticks([])
25+
fig.savefig("membrane_frontpage.png")

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4047,16 +4047,16 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
40474047
else:
40484048
collection.autoscale_None()
40494049

4050-
# The margin adjustment is a hack to deal with the fact that we don't
4051-
# want to transform all the symbols whose scales are in points
4052-
# to data coords to get the exact bounding box for efficiency
4053-
# reasons. It can be done right if this is deemed important.
4054-
# Also, only bother with this padding if there is anything to draw.
4055-
if self._xmargin < 0.05 and x.size > 0:
4056-
self.set_xmargin(0.05)
4057-
4058-
if self._ymargin < 0.05 and x.size > 0:
4059-
self.set_ymargin(0.05)
4050+
# Classic mode only:
4051+
# ensure there are margins to allow for the
4052+
# finite size of the symbols. In v2.x, margins
4053+
# are present by default, so we disable this
4054+
# scatter-specific override.
4055+
if rcParams['_internal.classic_mode']:
4056+
if self._xmargin < 0.05 and x.size > 0:
4057+
self.set_xmargin(0.05)
4058+
if self._ymargin < 0.05 and x.size > 0:
4059+
self.set_ymargin(0.05)
40604060

40614061
self.add_collection(collection)
40624062
self.autoscale_view()

0 commit comments

Comments
 (0)
0