Skip to content

Commit ba668f9

Browse files
committed
2 parents 641e823 + 57d66df commit ba668f9

File tree

17 files changed

+176
-99
lines changed

17 files changed

+176
-99
lines changed

doc/mpl_toolkits/axes_grid/users/overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ Curvilinear Grid
464464
The motivation behind the AxisArtist module is to support curvilinear grid
465465
and ticks.
466466

467-
.. plot:: mpl_toolkits/axes_grid/examples/demo_floating_axis.py
467+
.. plot:: mpl_toolkits/axes_grid/examples/demo_curvelinear_grid.py
468468

469469
See :ref:`axisartist-manual` for more details.
470470

doc/users/pyplot_tutorial.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ some change to a figure: e.g., create a figure, create a plotting area
1111
in a figure, plot some lines in a plotting area, decorate the plot
1212
with labels, etc.... :mod:`matplotlib.pyplot` is stateful, in that it
1313
keeps track of the current figure and plotting area, and the plotting
14-
functions are directed to the current axes
14+
functions are directed to the current axes (please note that "axes" here
15+
and in most places in the documentation refers to the *axes*
16+
`part of a figure <http://matplotlib.org/faq/usage_faq.html#parts-of-a-figure>`__
17+
and not the strict mathematical term for more than one axis).
1518

1619
.. plot:: pyplots/pyplot_simple.py
1720
:include-source:
@@ -164,7 +167,7 @@ scenes. Below is a script to create two subplots.
164167

165168
The :func:`~matplotlib.pyplot.figure` command here is optional because
166169
``figure(1)`` will be created by default, just as a ``subplot(111)``
167-
will be created by default if you don't manually specify an axes. The
170+
will be created by default if you don't manually specify any axes. The
168171
:func:`~matplotlib.pyplot.subplot` command specifies ``numrows,
169172
numcols, fignum`` where ``fignum`` ranges from 1 to
170173
``numrows*numcols``. The commas in the ``subplot`` command are
Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
#!/usr/bin/env python
2-
'''imshow with masked array input and out-of-range colors.
1+
"""
2+
imshow with masked array input and out-of-range colors.
33
4-
The second subplot illustrates the use of BoundaryNorm to
5-
get a filled contour effect.
6-
'''
4+
The second subplot illustrates the use of BoundaryNorm to
5+
get a filled contour effect.
6+
"""
77

8-
from pylab import *
98
from numpy import ma
109
import matplotlib.colors as colors
10+
import matplotlib.pyplot as plt
11+
import matplotlib.mlab as mlab
12+
import numpy as np
1113

1214
delta = 0.025
13-
x = y = arange(-3.0, 3.0, delta)
14-
X, Y = meshgrid(x, y)
15-
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
16-
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
15+
x = y = np.arange(-3.0, 3.0, delta)
16+
X, Y = np.meshgrid(x, y)
17+
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
18+
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
1719
Z = 10*(Z2 - Z1) # difference of Gaussians
1820

1921
# Set up a colormap:
20-
palette = cm.gray
22+
palette = plt.cm.gray
2123
palette.set_over('r', 1.0)
2224
palette.set_under('g', 1.0)
2325
palette.set_bad('b', 1.0)
@@ -33,22 +35,22 @@
3335
# range to which the regular palette color scale is applied.
3436
# Anything above that range is colored based on palette.set_over, etc.
3537

36-
subplot(1, 2, 1)
37-
im = imshow(Zm, interpolation='bilinear',
38-
cmap=palette,
39-
norm=colors.Normalize(vmin=-1.0, vmax=1.0, clip=False),
40-
origin='lower', extent=[-3, 3, -3, 3])
41-
title('Green=low, Red=high, Blue=bad')
42-
colorbar(im, extend='both', orientation='horizontal', shrink=0.8)
43-
44-
subplot(1, 2, 2)
45-
im = imshow(Zm, interpolation='nearest',
46-
cmap=palette,
47-
norm=colors.BoundaryNorm([-1, -0.5, -0.2, 0, 0.2, 0.5, 1],
48-
ncolors=256, clip=False),
49-
origin='lower', extent=[-3, 3, -3, 3])
50-
title('With BoundaryNorm')
51-
colorbar(im, extend='both', spacing='proportional',
52-
orientation='horizontal', shrink=0.8)
53-
54-
show()
38+
plt.subplot(1, 2, 1)
39+
im = plt.imshow(Zm, interpolation='bilinear',
40+
cmap=palette,
41+
norm=colors.Normalize(vmin=-1.0, vmax=1.0, clip=False),
42+
origin='lower', extent=[-3, 3, -3, 3])
43+
plt.title('Green=low, Red=high, Blue=bad')
44+
plt.colorbar(im, extend='both', orientation='horizontal', shrink=0.8)
45+
46+
plt.subplot(1, 2, 2)
47+
im = plt.imshow(Zm, interpolation='nearest',
48+
cmap=palette,
49+
norm=colors.BoundaryNorm([-1, -0.5, -0.2, 0, 0.2, 0.5, 1],
50+
ncolors=256, clip=False),
51+
origin='lower', extent=[-3, 3, -3, 3])
52+
plt.title('With BoundaryNorm')
53+
plt.colorbar(im, extend='both', spacing='proportional',
54+
orientation='horizontal', shrink=0.8)
55+
56+
plt.show()
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
#!/usr/bin/env python
21
"""
32
You can specify whether images should be plotted with the array origin
43
x[0,0] in the upper left or upper right by using the origin parameter.
54
You can also control the default be setting image.origin in your
65
matplotlibrc file; see http://matplotlib.org/matplotlibrc
76
"""
8-
from pylab import *
7+
import matplotlib.pyplot as plt
8+
import numpy as np
99

10-
x = arange(100.0)
10+
x = np.arange(100.0)
1111
x.shape = (10, 10)
1212

1313
interp = 'bilinear'
1414
#interp = 'nearest'
1515
lim = -2, 11, -2, 6
16-
subplot(211, axisbg='g')
17-
title('blue should be up')
18-
imshow(x, origin='upper', interpolation=interp)
19-
#axis(lim)
16+
plt.subplot(211, axisbg='g')
17+
plt.title('blue should be up')
18+
plt.imshow(x, origin='upper', interpolation=interp, cmap='jet')
19+
#plt.axis(lim)
2020

21-
subplot(212, axisbg='y')
22-
title('blue should be down')
23-
imshow(x, origin='lower', interpolation=interp)
24-
#axis(lim)
25-
show()
21+
plt.subplot(212, axisbg='y')
22+
plt.title('blue should be down')
23+
plt.imshow(x, origin='lower', interpolation=interp, cmap='jet')
24+
#plt.axis(lim)
25+
plt.show()
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
#!/usr/bin/env python
21
"""
3-
42
You can use decreasing axes by flipping the normal order of the axis
53
limits
6-
74
"""
8-
from pylab import *
95

10-
t = arange(0.01, 5.0, 0.01)
11-
s = exp(-t)
12-
plot(t, s)
6+
import matplotlib.pyplot as plt
7+
import numpy as np
8+
9+
t = np.arange(0.01, 5.0, 0.01)
10+
s = np.exp(-t)
11+
plt.plot(t, s)
1312

14-
xlim(5, 0) # decreasing time
13+
plt.xlim(5, 0) # decreasing time
1514

16-
xlabel('decreasing time (s)')
17-
ylabel('voltage (mV)')
18-
title('Should be growing...')
19-
grid(True)
15+
plt.xlabel('decreasing time (s)')
16+
plt.ylabel('voltage (mV)')
17+
plt.title('Should be growing...')
18+
plt.grid(True)
2019

21-
show()
20+
plt.show()
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
#!/usr/bin/env python
21
"""
32
Layer images above one another using alpha blending
43
"""
54
from __future__ import division
6-
from pylab import *
5+
import matplotlib.pyplot as plt
6+
import numpy as np
77

88

99
def func3(x, y):
10-
return (1 - x/2 + x**5 + y**3)*exp(-(x**2 + y**2))
10+
return (1 - x/2 + x**5 + y**3)*np.exp(-(x**2 + y**2))
1111

1212
# make these smaller to increase the resolution
1313
dx, dy = 0.05, 0.05
1414

15-
x = arange(-3.0, 3.0, dx)
16-
y = arange(-3.0, 3.0, dy)
17-
X, Y = meshgrid(x, y)
15+
x = np.arange(-3.0, 3.0, dx)
16+
y = np.arange(-3.0, 3.0, dy)
17+
X, Y = np.meshgrid(x, y)
1818

1919
# when layering multiple images, the images need to have the same
2020
# extent. This does not mean they need to have the same shape, but
@@ -24,20 +24,19 @@ def func3(x, y):
2424
# interpolation edge effects
2525

2626

27-
xmin, xmax, ymin, ymax = amin(x), amax(x), amin(y), amax(y)
27+
xmin, xmax, ymin, ymax = np.amin(x), np.amax(x), np.amin(y), np.amax(y)
2828
extent = xmin, xmax, ymin, ymax
2929
fig = plt.figure(frameon=False)
3030

31-
Z1 = array(([0, 1]*4 + [1, 0]*4)*4)
31+
Z1 = np.array(([0, 1]*4 + [1, 0]*4)*4)
3232
Z1.shape = (8, 8) # chessboard
33-
im1 = imshow(Z1, cmap=cm.gray, interpolation='nearest',
34-
extent=extent)
35-
hold(True)
33+
im1 = plt.imshow(Z1, cmap=plt.cm.gray, interpolation='nearest',
34+
extent=extent)
35+
plt.hold(True)
3636

3737
Z2 = func3(X, Y)
3838

39-
im2 = imshow(Z2, cmap=cm.jet, alpha=.9, interpolation='bilinear',
40-
extent=extent)
41-
#axis([xmin, xmax, ymin, ymax])
39+
im2 = plt.imshow(Z2, cmap=plt.cm.jet, alpha=.9, interpolation='bilinear',
40+
extent=extent)
4241

43-
show()
42+
plt.show()

lib/matplotlib/artist.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import re
77
import warnings
88
import inspect
9+
import numpy as np
910
import matplotlib
1011
import matplotlib.cbook as cbook
1112
from matplotlib.cbook import mplDeprecation
@@ -988,7 +989,8 @@ def format_cursor_data(self, data):
988989
data[0]
989990
except (TypeError, IndexError):
990991
data = [data]
991-
return ', '.join('{:0.3g}'.format(item) for item in data)
992+
return ', '.join('{:0.3g}'.format(item) for item in data if
993+
isinstance(item, (np.floating, np.integer, int, float)))
992994

993995
@property
994996
def mouseover(self):

lib/matplotlib/backends/backend_qt5.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,21 @@ def stop_event_loop(self):
416416
stop_event_loop.__doc__ = FigureCanvasBase.stop_event_loop_default.__doc__
417417

418418
def draw_idle(self):
419-
self.update()
419+
# This cannot be a call to 'update', we need a slightly longer
420+
# delay, otherwise mouse releases from zooming, panning, or
421+
# lassoing might not finish processing and will not redraw properly.
422+
# We use the guard flag to prevent infinite calls to 'draw_idle' which
423+
# happens with the 'stale' figure & axes callbacks.
424+
d = self._idle
425+
self._idle = False
426+
427+
def idle_draw(*args):
428+
try:
429+
self.draw()
430+
finally:
431+
self._idle = True
432+
if d:
433+
QtCore.QTimer.singleShot(0, idle_draw)
420434

421435

422436
class MainWindow(QtWidgets.QMainWindow):

lib/matplotlib/backends/backend_qt5agg.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ def paintEvent(self, e):
7171
In Qt, all drawing should be done inside of here when a widget is
7272
shown onscreen.
7373
"""
74-
FigureCanvasAgg.draw(self)
74+
# If we have not rendered the Agg backend yet, do so now.
75+
if not hasattr(self, 'renderer'):
76+
FigureCanvasAgg.draw(self)
7577

7678
# FigureCanvasQT.paintEvent(self, e)
7779
if DEBUG:

lib/matplotlib/collections.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,7 @@ def __init__(self, segments, # Can be None.
10531053
cmap=None,
10541054
pickradius=5,
10551055
zorder=2,
1056+
facecolors='none',
10561057
**kwargs
10571058
):
10581059
"""
@@ -1106,6 +1107,11 @@ def __init__(self, segments, # Can be None.
11061107
*zorder*
11071108
The zorder of the LineCollection. Default is 2
11081109
1110+
*facecolors*
1111+
The facecolors of the LineCollection. Default is 'none'
1112+
Setting to a value other than 'none' will lead to a filled
1113+
polygon being drawn between points on each line.
1114+
11091115
The use of :class:`~matplotlib.cm.ScalarMappable` is optional.
11101116
If the :class:`~matplotlib.cm.ScalarMappable` array
11111117
:attr:`~matplotlib.cm.ScalarMappable._A` is not None (i.e., a call to
@@ -1124,7 +1130,7 @@ def __init__(self, segments, # Can be None.
11241130
Collection.__init__(
11251131
self,
11261132
edgecolors=colors,
1127-
facecolors='none',
1133+
facecolors=facecolors,
11281134
linewidths=linewidths,
11291135
linestyles=linestyles,
11301136
antialiaseds=antialiaseds,

0 commit comments

Comments
 (0)