1.. _whats-new-1-4:
2
3
4New in matplotlib 1.4
5=====================
6
7Thomas A. Caswell served as the release manager for the 1.4 release.
8
9
10.. contents:: Table of Contents
11   :depth: 2
12
13
14.. note::
15
16   matplotlib 1.4 supports Python 2.6, 2.7, 3.3, and 3.4
17
18
19New colormap
20------------
21In heatmaps, a green-to-red spectrum is often used to indicate intensity of
22activity, but this can be problematic for the red/green colorblind. A new,
23colorblind-friendly colormap is now available at :class:`matplotlib.cm.Wistia`.
24This colormap maintains the red/green symbolism while achieving deuteranopic
25legibility through brightness variations. See
26`here <https://github.com/wistia/heatmap-palette>`__
27for more information.
28
29The nbagg backend
30-----------------
31Phil Elson added a new backend, named "nbagg", which enables interactive
32figures in a live IPython notebook session. The backend makes use of the
33infrastructure developed for the webagg backend, which itself gives
34standalone server backed interactive figures in the browser, however nbagg
35does not require a dedicated matplotlib server as all communications are
36handled through the IPython Comm machinery.
37
38As with other backends nbagg can be enabled inside the IPython notebook with::
39
40    import matplotlib
41    matplotlib.use('nbagg')
42
43Once figures are created and then subsequently shown, they will placed in an
44interactive widget inside the notebook allowing panning and zooming in the
45same way as any other matplotlib backend. Because figures require a connection
46to the IPython notebook server for their interactivity, once the notebook is
47saved, each figure will be rendered as a static image - thus allowing
48non-interactive viewing of figures on services such as
49`nbviewer <http://nbviewer.ipython.org/>`__.
50
51
52
53New plotting features
54---------------------
55
56Power-law normalization
57```````````````````````
58Ben Gamari added a power-law normalization method,
59:class:`~matplotlib.colors.PowerNorm`. This class maps a range of
60values to the interval [0,1] with power-law scaling with the exponent
61provided by the constructor's `gamma` argument. Power law normalization
62can be useful for, e.g., emphasizing small populations in a histogram.
63
64Fully customizable boxplots
65```````````````````````````
66Paul Hobson overhauled the :func:`~matplotlib.pyplot.boxplot` method such
67that it is now completely customizable in terms of the styles and positions
68of the individual artists. Under the hood, :func:`~matplotlib.pyplot.boxplot`
69relies on a new function (:func:`~matplotlib.cbook.boxplot_stats`), which
70accepts any data structure currently compatible with
71:func:`~matplotlib.pyplot.boxplot`, and returns a list of dictionaries
72containing the positions for each element of the boxplots. Then
73a second method, :func:`~matplotlib.Axes.bxp` is called to draw the boxplots
74based on the stats.
75
76The :func:`~matplotlib.pyplot.boxplot` function can be used as before to
77generate boxplots from data in one step. But now the user has the
78flexibility to generate the statistics independently, or to modify the
79output of :func:`~matplotlib.cbook.boxplot_stats` prior to plotting
80with :func:`~matplotlib.Axes.bxp`.
81
82Lastly, each artist (e.g., the box, outliers, cap, notches) can now be
83toggled on or off and their styles can be passed in through individual
84kwargs. See the examples:
85:doc:`/gallery/statistics/boxplot` and
86:doc:`/gallery/statistics/bxp`
87
88Added a bool kwarg, :code:`manage_xticks`, which if False disables the management
89of the ticks and limits on the x-axis by :func:`~matplotlib.axes.Axes.bxp`.
90
91Support for datetime axes in 2d plots
92`````````````````````````````````````
93Andrew Dawson added support for datetime axes to
94:func:`~matplotlib.pyplot.contour`, :func:`~matplotlib.pyplot.contourf`,
95:func:`~matplotlib.pyplot.pcolormesh` and :func:`~matplotlib.pyplot.pcolor`.
96
97Support for additional spectrum types
98`````````````````````````````````````
99Todd Jennings added support for new types of frequency spectrum plots:
100:func:`~matplotlib.pyplot.magnitude_spectrum`,
101:func:`~matplotlib.pyplot.phase_spectrum`, and
102:func:`~matplotlib.pyplot.angle_spectrum`, as well as corresponding functions
103in mlab.
104
105He also added these spectrum types to :func:`~matplotlib.pyplot.specgram`,
106as well as adding support for linear scaling there (in addition to the
107existing dB scaling). Support for additional spectrum types was also added to
108:func:`~matplotlib.mlab.specgram`.
109
110He also increased the performance for all of these functions and plot types.
111
112Support for detrending and windowing 2D arrays in mlab
113``````````````````````````````````````````````````````
114Todd Jennings added support for 2D arrays in the
115:func:`~matplotlib.mlab.detrend_mean`, :func:`~matplotlib.mlab.detrend_none`,
116and :func:`~matplotlib.mlab.detrend`, as well as adding
117:func:`~matplotlib.mlab.apply_window` which support windowing 2D arrays.
118
119Support for strides in mlab
120```````````````````````````
121Todd Jennings added some functions to mlab to make it easier to use numpy
122strides to create memory-efficient 2D arrays.  This includes
123:func:`~matplotlib.mlab.stride_repeat`, which repeats an array to create a 2D
124array, and :func:`~matplotlib.mlab.stride_windows`, which uses a moving window
125to create a 2D array from a 1D array.
126
127Formatter for new-style formatting strings
128``````````````````````````````````````````
129Added `FormatStrFormatterNewStyle` which does the same job as
130`FormatStrFormatter`, but accepts new-style formatting strings
131instead of printf-style formatting strings
132
133Consistent grid sizes in streamplots
134````````````````````````````````````
135:func:`~matplotlib.pyplot.streamplot` uses a base grid size of 30x30 for both
136`density=1` and `density=(1, 1)`. Previously a grid size of 30x30 was used for
137`density=1`, but a grid size of 25x25 was used for `density=(1, 1)`.
138
139Get a list of all tick labels (major and minor)
140```````````````````````````````````````````````
141Added the `kwarg` 'which' to :func:`~matplotlib.Axes.get_xticklabels`,
142:func:`~matplotlib.Axes.get_yticklabels` and
143:func:`~matplotlib.Axis.get_ticklabels`.  'which' can be 'major', 'minor', or
144'both' select which ticks to return, like
145:func:`~matplotlib.Axis.set_ticks_position`.  If 'which' is `None` then the old
146behaviour (controlled by the bool `minor`).
147
148Separate horizontal/vertical axes padding support in ImageGrid
149``````````````````````````````````````````````````````````````
150The `kwarg` 'axes_pad' to :class:`mpl_toolkits.axes_grid1.ImageGrid` can now
151be a tuple if separate horizontal/vertical padding is needed.
152This is supposed to be very helpful when you have a labelled legend next to
153every subplot and you need to make some space for legend's labels.
154
155Support for skewed transformations
156``````````````````````````````````
157The :class:`~matplotlib.transforms.Affine2D` gained additional methods
158`skew` and `skew_deg` to create skewed transformations. Additionally,
159matplotlib internals were cleaned up to support using such transforms in
160:class:`~matplotlib.Axes`. This transform is important for some plot types,
161specifically the Skew-T used in meteorology.
162
163.. figure:: ../../gallery/api/images/sphx_glr_skewt_001.png
164   :target: ../../gallery/api/skewt.html
165   :align: center
166   :scale: 50
167
168   Skewt
169
170Support for specifying properties of wedge and text in pie charts.
171``````````````````````````````````````````````````````````````````
172Added the `kwargs` 'wedgeprops' and 'textprops' to :func:`~matplotlib.Axes.pie`
173to accept properties for wedge and text objects in a pie. For example, one can
174specify wedgeprops = {'linewidth':3} to specify the width of the borders of
175the wedges in the pie. For more properties that the user can specify, look at
176the docs for the wedge and text objects.
177
178Fixed the direction of errorbar upper/lower limits
179``````````````````````````````````````````````````
180Larry Bradley fixed the :func:`~matplotlib.pyplot.errorbar` method such
181that the upper and lower limits (*lolims*, *uplims*, *xlolims*,
182*xuplims*) now point in the correct direction.
183
184More consistent add-object API for Axes
185```````````````````````````````````````
186Added the Axes method `~matplotlib.axes.Axes.add_image` to put image
187handling on a par with artists, collections, containers, lines, patches,
188and tables.
189
190Violin Plots
191````````````
192Per Parker, Gregory Kelsie, Adam Ortiz, Kevin Chan, Geoffrey Lee, Deokjae
193Donald Seo, and Taesu Terry Lim added a basic implementation for violin
194plots. Violin plots can be used to represent the distribution of sample data.
195They are similar to box plots, but use a kernel density estimation function to
196present a smooth approximation of the data sample used. The added features are:
197
198:func:`~matplotlib.Axes.violin` - Renders a violin plot from a collection of
199statistics.
200:func:`~matplotlib.cbook.violin_stats` - Produces a collection of statistics
201suitable for rendering a violin plot.
202:func:`~matplotlib.pyplot.violinplot` - Creates a violin plot from a set of
203sample data. This method makes use of :func:`~matplotlib.cbook.violin_stats`
204to process the input data, and :func:`~matplotlib.cbook.violin_stats` to
205do the actual rendering. Users are also free to modify or replace the output of
206:func:`~matplotlib.cbook.violin_stats` in order to customize the violin plots
207to their liking.
208
209This feature was implemented for a software engineering course at the
210University of Toronto, Scarborough, run in Winter 2014 by Anya Tafliovich.
211
212More `markevery` options to show only a subset of markers
213`````````````````````````````````````````````````````````
214Rohan Walker extended the `markevery` property in
215:class:`~matplotlib.lines.Line2D`.  You can now specify a subset of markers to
216show with an int, slice object, numpy fancy indexing, or float. Using a float
217shows markers at approximately equal display-coordinate-distances along the
218line.
219
220Added size related functions to specialized `Collections`
221`````````````````````````````````````````````````````````
222
223Added the `get_size` and `set_size` functions to control the size of
224elements of specialized collections (
225:class:`~matplotlib.collections.AsteriskPolygonCollection`
226:class:`~matplotlib.collections.BrokenBarHCollection`
227:class:`~matplotlib.collections.CircleCollection`
228:class:`~matplotlib.collections.PathCollection`
229:class:`~matplotlib.collections.PolyCollection`
230:class:`~matplotlib.collections.RegularPolyCollection`
231:class:`~matplotlib.collections.StarPolygonCollection`).
232
233
234Fixed the mouse coordinates giving the wrong theta value in Polar graph
235```````````````````````````````````````````````````````````````````````
236Added code to
237:func:`~matplotlib.InvertedPolarTransform.transform_non_affine`
238to ensure that the calculated theta value was between the range of 0 and 2 * pi
239since the problem was that the value can become negative after applying the
240direction and rotation to the theta calculation.
241
242Simple quiver plot for mplot3d toolkit
243``````````````````````````````````````
244A team of students in an *Engineering Large Software Systems* course, taught
245by Prof. Anya Tafliovich at the University of Toronto, implemented a simple
246version of a quiver plot in 3D space for the mplot3d toolkit as one of their
247term project. This feature is documented in :func:`~mpl_toolkits.mplot3d.Axes3D.quiver`.
248The team members are: Ryan Steve D'Souza, Victor B, xbtsw, Yang Wang, David,
249Caradec Bisesar and Vlad Vassilovski.
250
251.. figure:: ../../gallery/mplot3d/images/sphx_glr_quiver3d_001.png
252   :target: ../../gallery/mplot3d/quiver3d.html
253   :align: center
254   :scale: 50
255
256   Quiver3d
257
258polar-plot r-tick locations
259```````````````````````````
260Added the ability to control the angular position of the r-tick labels
261on a polar plot via :func:`~matplotlib.Axes.axes.set_rlabel_position`.
262
263
264Date handling
265-------------
266
267n-d array support for date conversion
268``````````````````````````````````````
269Andrew Dawson added support for n-d array handling to
270:func:`matplotlib.dates.num2date`, :func:`matplotlib.dates.date2num`
271and :func:`matplotlib.dates.datestr2num`. Support is also added to the unit
272conversion interfaces :class:`matplotlib.dates.DateConverter` and
273:class:`matplotlib.units.Registry`.
274
275
276Configuration (rcParams)
277------------------------
278
279
280``savefig.transparent`` added
281`````````````````````````````
282Controls whether figures are saved with a transparent
283background by default.  Previously `savefig` always defaulted
284to a non-transparent background.
285
286
287``axes.titleweight``
288````````````````````
289Added rcParam to control the weight of the title
290
291``axes.formatter.useoffset`` added
292``````````````````````````````````
293Controls the default value of `useOffset` in `ScalarFormatter`.  If
294`True` and the data range is much smaller than the data average, then
295an offset will be determined such that the tick labels are
296meaningful. If `False` then the full number will be formatted in all
297conditions.
298
299``nbagg.transparent`` added
300`````````````````````````````
301Controls whether nbagg figures have a transparent
302background. ``nbagg.transparent`` is ``True`` by default.
303
304
305XDG compliance
306``````````````
307Matplotlib now looks for configuration files (both rcparams and style) in XDG
308compliant locations.
309
310``style`` package added
311-----------------------
312You can now easily switch between different styles using the new ``style``
313package::
314
315   >>> from matplotlib import style
316   >>> style.use('dark_background')
317
318Subsequent plots will use updated colors, sizes, etc. To list all available
319styles, use::
320
321   >>> print style.available
322
323You can add your own custom ``<style name>.mplstyle`` files to
324``~/.matplotlib/stylelib`` or call ``use`` with a URL pointing to a file with
325``matplotlibrc`` settings.
326
327*Note that this is an experimental feature*, and the interface may change as
328users test out this new feature.
329
330Backends
331--------
332Qt5 backend
333```````````
334Martin Fitzpatrick and Tom Badran implemented a Qt5 backend.  The differences
335in namespace locations between Qt4 and Qt5 was dealt with by shimming
336Qt4 to look like Qt5, thus the Qt5 implementation is the primary implementation.
337Backwards compatibility for Qt4 is maintained by wrapping the Qt5 implementation.
338
339The Qt5Agg backend currently does not work with IPython's %matplotlib magic.
340
341The 1.4.0 release has a known bug where the toolbar is broken.  This can be
342fixed by: ::
343
344   cd path/to/installed/matplotlib
345   wget https://github.com/matplotlib/matplotlib/pull/3322.diff
346   # unix2dos 3322.diff (if on windows to fix line endings)
347   patch -p2 < 3322.diff
348
349Qt4 backend
350```````````
351Rudolf Höfler changed the appearance of the subplottool. All sliders are
352vertically arranged now, buttons for tight layout and reset were
353added. Furthermore, the subplottool is now implemented as a modal
354dialog. It was previously a QMainWindow, leaving the SPT open if one closed the
355plot window.
356
357In the figure options dialog one can now choose to (re-)generate a simple
358automatic legend. Any explicitly set legend entries will be lost, but changes to
359the curves' label, linestyle, et cetera will now be updated in the legend.
360
361Interactive performance of the Qt4 backend has been dramatically improved
362under windows.
363
364The mapping of key-signals from Qt to values matplotlib understands
365was greatly improved (For both Qt4 and Qt5).
366
367Cairo backends
368``````````````
369
370The Cairo backends are now able to use the `cairocffi bindings
371<https://github.com/SimonSapin/cairocffi>`__ which are more actively
372maintained than the `pycairo bindings
373<https://www.cairographics.org/pycairo/>`__.
374
375Gtk3Agg backend
376```````````````
377
378The Gtk3Agg backend now works on Python 3.x, if the `cairocffi
379bindings <https://github.com/SimonSapin/cairocffi>`__ are installed.
380
381PDF backend
382```````````
383Added context manager for saving to multi-page PDFs.
384
385Text
386----
387
388Text URLs supported by SVG backend
389``````````````````````````````````
390
391The `svg` backend will now render :class:`~matplotlib.text.Text` objects'
392url as a link in output SVGs.  This allows one to make clickable text in
393saved figures using the url kwarg of the :class:`~matplotlib.text.Text`
394class.
395
396Anchored sizebar font
397`````````````````````
398Added the ``fontproperties`` kwarg to
399:class:`~matplotilb.mpl_toolkits.axes_grid.anchored_artists.AnchoredSizeBar` to
400control the font properties.
401
402Sphinx extensions
403-----------------
404
405The ``:context:`` directive in the `~matplotlib.sphinxext.plot_directive`
406Sphinx extension can now accept an optional ``reset`` setting, which will
407cause the context to be reset. This allows more than one distinct context to
408be present in documentation. To enable this option, use ``:context: reset``
409instead of ``:context:`` any time you want to reset the context.
410
411Legend and PathEffects documentation
412------------------------------------
413The :doc:`/tutorials/intermediate/legend_guide` and :doc:`/tutorials/advanced/patheffects_guide` have both been
414updated to better reflect the full potential of each of these powerful
415features.
416
417Widgets
418-------
419
420Span Selector
421`````````````
422
423Added an option ``span_stays`` to the
424:class:`~matplotlib.widgets.SpanSelector` which makes the selector
425rectangle stay on the axes after you release the mouse.
426
427GAE integration
428---------------
429Matplotlib will now run on google app engine.
430