10000 Merge remote-tracking branch 'upstream/master' · matplotlib/matplotlib@6e50219 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6e50219

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents b8ae7bd + 4c70e91 commit 6e50219

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+663
-460
lines changed

.flake8

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ per-file-ignores =
5959
lib/mpl_toolkits/axes_grid1/colorbar.py: E225, E501
6060
lib/mpl_toolkits/axisartist/angle_helper.py: E221
6161
lib/mpl_toolkits/axisartist/clip_path.py: E225
62-
lib/mpl_toolkits/axisartist/floating_axes.py: E225, E402, E501
6362
lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py: E225, E501
6463

6564
doc/conf.py: E402, E501

INSTALL.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,15 @@ Optionally, you can also install a number of packages to enable better user
147147
interface toolkits. See :ref:`what-is-a-backend` for more details on the
148148
optional Matplotlib backends and the capabilities they provide.
149149

150-
* :term:`tk` (>= 8.3, != 8.6.0 or 8.6.1): for the Tk-based backends;
150+
* `Tk <https://docs.python.org/3/library/tk.html>`_ (>= 8.3, != 8.6.0 or
151+
8.6.1): for the Tk-based backends;
151152
* `PyQt4 <https://pypi.org/project/PyQt4>`_ (>= 4.6) or
152153
`PySide <https://pypi.org/project/PySide>`_ (>= 1.0.3): for the Qt4-based
153154
backends;
154155
* `PyQt5 <https://pypi.org/project/PyQt5>`_: for the Qt5-based backends;
155156
* `PyGObject <https://pypi.org/project/PyGObject/>`_: for the GTK3-based
156157
backends;
157-
* :term:`wxpython` (>= 4): for the WX-based backends;
158+
* `wxPython <https://www.wxpython.org/>`_ (>= 4): for the WX-based backends;
158159
* `cairocffi <https://cairocffi.readthedocs.io/en/latest/>`_ (>= 0.8) or
159160
`pycairo <https://pypi.org/project/pycairo>`_: for the cairo-based
160161
backends;
87.3 KB
Loading

doc/_templates/layout.html

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,10 @@ <h3>{{ _('Navigation') }}</h3>
7676
{%- endmacro %}
7777

7878
{%- macro script() %}
79-
{% if sphinx_version >= "1.8.0" %}
80-
<script type="text/javascript" id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
81-
{%- for scriptfile in script_files %}
82-
{{ js_tag(scriptfile) }}
83-
{%- endfor %}
84-
{% else %}
85-
<script type="text/javascript">
86-
var DOCUMENTATION_OPTIONS = {
87-
URL_ROOT:'{{ url_root }}',
88-
VERSION:'{{ release|e }}',
89-
LANGUAGE:'{{ language }}',
90-
COLLAPSE_INDEX:false,
91-
FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}',
92-
HAS_SOURCE: {{ has_source|lower }},
93-
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}'
94-
};
95-
</script>
96-
{%- for scriptfile in script_files %}
97-
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
98-
{%- endfor %}
99-
{% endif %}
79+
<script type="text/javascript" id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
80+
{%- for scriptfile in script_files %}
81+
{{ js_tag(scriptfile) }}
82+
{%- endfor %}
10083
{%- endmacro %}
10184

10285
{%- macro css() %}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Autoscaling changes
2+
```````````````````
3+
4+
Matplotlib used to recompute autoscaled limits after every plotting
5+
(``plot()``, ``bar()``, etc.) call. It now only does so when actually
6+
rendering the canvas, or when the user queries the Axes limits. This is a
7+
major performance improvement for plots with a large number of artists.
8+
9+
In particular, this means that artists added manually with `Axes.add_line`,
10+
`Axes.add_patch`, etc. will be taken into account by the autoscale, even
11+
without an explicit call to `Axes.autoscale_view`.
12+
13+
In some cases, this can result in different limits being reported. If this is
14+
an issue, consider triggering a draw with `fig.canvas.draw`.
15+
16+
LogLocator.nonsingular now maintains the orders of its arguments
17+
````````````````````````````````````````````````````````````````
18+
19+
It no longer reorders them in increasing order. The new behavior is consistent
20+
with MaxNLocator.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Change in the application of ``Artist.sticky_edges``
2+
````````````````````````````````````````````````````
3+
4+
Previously, the ``sticky_edges`` attribute of artists was a list of values such
5+
that if an axis limit coincides with a sticky edge, it would not be expanded by
6+
the axes margins (this is the mechanism that e.g. prevents margins from being
7+
added around images).
8+
9+
``sticky_edges`` now have an additional effect on margins application: even if
10+
an axis limit did not coincide with a sticky edge, it cannot *cross* a sticky
11+
edge through margin application -- instead, the margins will only expand the
12+
axis limit until it bumps against the sticky edge.
13+
14+
This change improves the margins of axes displaying a `~Axes.streamplot`:
15+
16+
- if the streamplot goes all the way to the edges of the vector field, then the
17+
axis limits are set to match exactly the vector field limits (whereas they
18+
would be sometimes be off by a small floating point error previously).
19+
- if the streamplot does not reach the edges of the vector field (e.g., due to
20+
the use of ``start_points`` and ``maxlength``), then margins expansion will
21+
not cross the the vector field limits anymore.
22+
23+
This change is also used internally to ensure that polar plots don't display
24+
negative *r* values unless the user really passes in a negative value.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations
2+
````````````
3+
4+
``FigureCanvasMac.invalidate`` is deprecated in favor of its synonym,
5+
``FigureCanvasMac.draw_idle``.

doc/glossary/index.rst

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -14,58 +14,15 @@ Glossary
1414
Cairo
1515
The `Cairo graphics <https://cairographics.org>`_ engine
1616

17-
18-
dateutil
19-
The `dateutil <https://dateutil.readthedocs.io>`_ library
20-
provides extensions to the standard datetime module
21-
22-
EPS
23-
Encapsulated Postscript (`EPS
24-
<https://en.wikipedia.org/wiki/Encapsulated_PostScript>`_)
25-
2617
FreeType
2718
`FreeType <https://www.freetype.org/>`_ is a font rasterization
2819
library used by matplotlib which supports TrueType, Type 1, and
2920
OpenType fonts.
3021

31-
GDK
32-
The Gimp Drawing Kit for GTK+
33-
3422
GTK
3523
The GIMP Toolkit (`GTK <https://www.gtk.org/>`_) graphical user interface
3624
library
3725

38-
JPG
39-
The Joint Photographic Experts Group (`JPEG
40-
<https://en.wikipedia.org/wiki/Jpeg>`_) compression method and
41-
file format for photographic images
42-
43-
numpy
44-
`numpy <http://www.numpy.org/>`_ is the standard numerical
45-
array library for python, the successor to Numeric and numarray.
46-
numpy provides fast operations for homogeneous data sets and
47-
common mathematical operations like correlations, standard
48-
deviation, fourier transforms, and convolutions.
49-
50-
PDF
51-
Adobe's Portable Document Format (`PDF
52-
<https://en.wikipedia.org/wiki/Portable_Document_Format>`_)
53-
54-
PNG
55-
Portable Network Graphics (`PNG
56-
<https://en.wikipedia.org/wiki/Portable_Network_Graphics>`_), a raster
57-
graphics format that employs lossless data compression which is more
58-
suitable for line art than the lossy jpg format. Unlike the gif format,
59-
png is not encumbered by requirements for a patent license.
60-
61-
PS
62-
Postscript (`PS <https://en.wikipedia.org/wiki/PostScript>`_) is a
63-
vector graphics ASCII text language widely used in printers and
64-
publishing. Postscript was developed by adobe systems and is
65-
starting to show its age: for example is does not have an alpha
66-
channel. PDF was designed in part as a next-generation document
67-
format to replace postscript
68-
6926
PyGObject
7027
`PyGObject <http://www.pygtk.org/>`_ provides Python wrappers for the
7128
:term:`GTK` widgets library
@@ -77,11 +34,6 @@ Glossary
7734
and windows; many linux distributions package this as
7835
'python-qt5' or 'python-qt4'.
7936

80-
python
81-
`python <https://www.python.org>`_ is an object oriented interpreted
82-
language widely used for scripting, application development, web
83-
application servers, scientific computing and more.
84-
8537
Qt
8638
`Qt <https://www.qt.io/>`__ is a cross-platform
8739
application framework for desktop and embedded development.
@@ -96,42 +48,12 @@ Glossary
9648
version of Qt cross-platform application
9749
framework for desktop and embedded development.
9850

99-
raster graphics
100-
`Raster graphics
101-
<https://en.wikipedia.org/wiki/Raster_graphics>`_, or bitmaps,
102-
represent an image as an array of pixels which is resolution
103-
dependent. Raster graphics are generally most practical for
104-
photo-realistic images, but do not scale easily without loss of
105-
quality.
106-
107-
SVG
108-
The Scalable Vector Graphics format (`SVG
109-
<https://en.wikipedia.org/wiki/Svg>`_). An XML based vector
110-
graphics format supported by many web browsers.
111-
112-
TIFF
113-
Tagged Image File Format (`TIFF
114-
<https://en.wikipedia.org/wiki/Tagged_Image_File_Format>`_) is a
115-
file format for storing images, including photographs and line
116-
art.
117-
11851
Tk
11952
`Tk <http://www.tcl.tk/>`_ is a graphical user interface for Tcl
12053
and many other dynamic languages. It can produce rich, native
12154
applications that run unchanged across Windows, Mac OS X, Linux
12255
and more.
12356

124-
vector graphics
125-
`vector graphics
126-
<https://en.wikipedia.org/wiki/Vector_graphics>`_ use geometrical
127-
primitives based upon mathematical equations to represent images
128-
in computer graphics. Primitives can include points, lines,
129-
curves, and shapes or polygons. Vector graphics are scalable,
130-
which means that they can be resized without suffering from
131-
issues related to inherent resolution like are seen in raster
132-
graphics. Vector graphics are generally most practical for
133-
typesetting and graphic design applications.
134-
13557
wxpython
13658
`wxpython <https://www.wxpython.org/>`_ provides python wrappers
13759
for the :term:`wxWidgets` library for use with the WX and WXAgg

doc/thirdpartypackages/index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ data processing tools. An example plot from the `Cartopy gallery
3535
.. image:: /_static/cartopy_hurricane_katrina_01_00.png
3636
:height: 400px
3737

38+
Ridge Map
39+
=========
40+
`ridge_map <https://github.com/ColCarroll/ridge_map>`_ uses Matplotlib,
41+
SRTM.py, NumPy, and scikit-image to make ridge plots of your favorite
42+
ridges.
43+
44+
.. image:: /_static/ridge_map_white_mountains.png
45+
:height: 364px
46+
3847
Declarative libraries
3948
*********************
4049

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
`~pyplot.imsave` gained support for the ``metadata`` and ``pil_kwargs`` parameters
2+
``````````````````````````````````````````````````````````````````````````````````
3+
4+
These parameters behave similarly as for the `Figure.savefig()` method.
Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
"""
2-
============
3-
Gradient Bar
4-
============
2+
========================
3+
Bar chart with gradients
4+
========================
5+
6+
Matplotlib does not natively support gradients. However, we can emulate a
7+
gradient-filled rectangle by an `.AxesImage` of the right size and coloring.
8+
9+
In particular, we use a colormap to generate the actual colors. It is then
10+
sufficient to define the underlying values on the corners of the image and
11+
let bicubic interpolation fill out the area. We define the gradient direction
12+
by a unit vector *v*. The values at the corners are then obtained by the
13+
lengths of the projections of the corner vectors on *v*.
14+
15+
A similar approach can be used to create a gradient background for an axes.
16+
In that case, it is helpful to uses Axes coordinates
17+
(`extent=(0, 1, 0, 1), transform=ax.transAxes`) to be independent of the data
18+
coordinates.
519
620
"""
721
import matplotlib.pyplot as plt
@@ -10,12 +24,44 @@
1024
np.random.seed(19680801)
1125

1226

13-
def gbar(ax, x, y, width=0.5, bottom=0):
14-
X = [[.6, .6], [.7, .7]]
27+
def gradient_image(ax, extent, direction=0.3, cmap_range=(0, 1), **kwargs):
28+
"""
29+
Draw a gradient image based on a colormap.
30+
31+
Parameters
32+
----------
33+
ax : Axes
34+
The axes to draw on.
35+
extent
36+
The extent of the image as (xmin, xmax, ymin, ymax).
37+
By default, this is in Axes coordinates but may be
38+
changed using the *transform* kwarg.
39+
direction : float
40+
The direction of the gradient. This is a number in
41+
range 0 (=vertical) to 1 (=horizontal).
42+
cmap_range : float, float
43+
The fraction (cmin, cmax) of the colormap that should be
44+
used for the gradient, where the complete colormap is (0, 1).
45+
**kwargs
46+
Other parameters are passed on to `.Axes.imshow()`.
47+
In particular useful is *cmap*.
48+
"""
49+
phi = direction * np.pi / 2
50+
v = np.array([np.cos(phi), np.sin(phi)])
51+
X = np.array([[v @ [1, 0], v @ [1, 1]],
52+
[v @ [0, 0], v @ [0, 1]]])
53+
a, b = cmap_range
54+
X = a + (b - a) / X.max() * X
55+
im = ax.imshow(X, extent=extent, interpolation='bicubic',
56+
vmin=0, vmax=1, **kwargs)
57+
return im
58+
59+
60+
def gradient_bar(ax, x, y, width=0.5, bottom=0):
1561
for left, top in zip(x, y):
1662
right = left + width
17-
ax.imshow(X, interpolation='bicubic', cmap=plt.cm.Blues,
18-
extent=(left, right, bottom, top), alpha=1)
63+
gradient_image(ax, extent=(left, right, bottom, top),
64+
cmap=plt.cm.Blues_r, cmap_range=(0, 0.8))
1965

2066

2167
xmin, xmax = xlim = 0, 10
@@ -24,13 +70,13 @@ def gbar(ax, x, y, width=0.5, bottom=0):
2470
fig, ax = plt.subplots()
2571
ax.set(xlim=xlim, ylim=ylim, autoscale_on=False)
2672

27-
X = [[.6, .6], [.7, .7]]
28-
ax.imshow(X, interpolation='bicubic', cmap=plt.cm.copper,
29-
extent=(xmin, xmax, ymin, ymax), alpha=1)
73+
# background image
74+
gradient_image(ax, direction=0, extent=(0, 1, 0, 1), transform=ax.transAxes,
75+
cmap=plt.cm.Oranges, cmap_range=(0.1, 0.6))
3076

3177
N = 10
32-
x = np.arange(N) + 0.25
78+
x = np.arange(N) + 0.15
3379
y = np.random.rand(N)
34-
gbar(ax, x, y, width=0.7)
80+
gradient_bar(ax, x, y, width=0.7)
3581
ax.set_aspect('auto')
3682
plt.show()

0 commit comments

Comments
 (0)
0