|
| 1 | +.. _whats-new-2-0-0: |
| 2 | + |
| 3 | +New in matplotlib 2.0 |
| 4 | +===================== |
| 5 | + |
| 6 | +.. note:: |
| 7 | + |
| 8 | + matplotlib 2.0 supports Python 2.7, and 3.4+ |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +Default style changes |
| 13 | +--------------------- |
| 14 | + |
| 15 | +The major changes in v2.0 are related to overhauling the default styles. |
| 16 | + |
| 17 | +.. toctree:: |
| 18 | + :maxdepth: 2 |
| 19 | + |
| 20 | + ../dflt_style_changes |
| 21 | + |
| 22 | + |
| 23 | +Improved color conversion API and RGBA support |
| 24 | +---------------------------------------------- |
| 25 | + |
| 26 | +The :mod:`~matplotlib.colors` gained a new color conversion API with |
| 27 | +full support for the alpha channel. The main public functions are |
| 28 | +:func:`~matplotlib.colors.is_color_like`, :func:`matplotlib.colors.to_rgba`, |
| 29 | +:func:`matplotlib.colors.to_rgba_array` and :func:`~matplotlib.colors.to_hex`. |
| 30 | +RGBA quadruplets are encoded in hex format as `#rrggbbaa`. |
| 31 | + |
| 32 | +A side benefit is that the Qt options editor now allows setting the alpha |
| 33 | +channel of the artists as well. |
| 34 | + |
| 35 | + |
| 36 | +New Configuration (rcParams) |
| 37 | +---------------------------- |
| 38 | + |
| 39 | +New rcparams added |
| 40 | + |
| 41 | ++---------------------------------+--------------------------------------------------+ |
| 42 | +| Parameter | Description | |
| 43 | ++=================================+==================================================+ |
| 44 | +|`date.autoformatter.year` | format string for 'year' scale dates | |
| 45 | ++---------------------------------+--------------------------------------------------+ |
| 46 | +|`date.autoformatter.month` | format string for 'month' scale dates | |
| 47 | ++---------------------------------+--------------------------------------------------+ |
| 48 | +|`date.autoformatter.day` | format string for 'day' scale dates | |
| 49 | ++---------------------------------+--------------------------------------------------+ |
| 50 | +|`date.autoformatter.hour` | format string for 'hour' scale times | |
| 51 | ++---------------------------------+--------------------------------------------------+ |
| 52 | +|`date.autoformatter.minute` | format string for 'minute' scale times | |
| 53 | ++---------------------------------+--------------------------------------------------+ |
| 54 | +|`date.autoformatter.second` | format string for 'second' scale times | |
| 55 | ++---------------------------------+--------------------------------------------------+ |
| 56 | +|`date.autoformatter.microsecond` | format string for 'microsecond' scale times | |
| 57 | ++---------------------------------+--------------------------------------------------+ |
| 58 | +|`scatter.marker` | default marker for scatter plot | |
| 59 | ++---------------------------------+--------------------------------------------------+ |
| 60 | +|`svg.hashsalt` | see note | |
| 61 | ++---------------------------------+--------------------------------------------------+ |
| 62 | +|`xtick.top`, `xtick.minor.top`, | Control where major and minor ticks are drawn. | |
| 63 | +|`xtick.major.top` | The global values are `and` ed with the | |
| 64 | +|`xtick.bottom`, | corresponding major/minor values. | |
| 65 | +|`xtick.minor.bottom`, | | |
| 66 | +|`xtick.major.bottom` | | |
| 67 | +|`ytick.left`, `ytick.minor.left`,| | |
| 68 | +|`ytick.major.left` | | |
| 69 | +|`ytick.right`, | | |
| 70 | +|`ytick.minor.right`, | | |
| 71 | +|`ytick.major.right` | | |
| 72 | ++---------------------------------+--------------------------------------------------+ |
| 73 | +|`hist.bins` | The default number of bins to use in | |
| 74 | +| | `~matplotlib.axes.Axes.hist`. This can be an | |
| 75 | +| | `int`, a list of floats, or ``'auto'`` if numpy | |
| 76 | +| | >= 1.11 is installed. | |
| 77 | ++---------------------------------+--------------------------------------------------+ |
| 78 | +|`lines.scale_dashes` | Whether the line dash patterns should scale with | |
| 79 | +| | linewidth. | |
| 80 | ++---------------------------------+--------------------------------------------------+ |
| 81 | +|`axes.formatter.offset_threshold`| Minimum number of digits saved in tick labels | |
| 82 | +| | that triggers using an offset. | |
| 83 | ++---------------------------------+--------------------------------------------------+ |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | +Added ``svg.hashsalt`` key to rcParams |
| 88 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 89 | + |
| 90 | +If ``svg.hashsalt`` is ``None`` (which it is by default), the svg |
| 91 | +backend uses ``uuid4`` to generate the hash salt. If it is not |
| 92 | +``None``, it must be a string that is used as the hash salt instead of |
| 93 | +``uuid4``. This allows for deterministic SVG output. |
| 94 | + |
| 95 | + |
| 96 | +Removed the ``svg.image_noscale`` rcParam |
| 97 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 98 | + |
| 99 | +As a result of the extensive changes to image handling, the |
| 100 | +``svg.image_noscale`` rcParam has been removed. The same |
| 101 | +functionality may be achieved by setting ``interpolation='none'`` on |
| 102 | +individual images or globally using the ``image.interpolation`` |
| 103 | +rcParam. |
| 104 | + |
| 105 | + |
| 106 | +Qualitative colormaps |
| 107 | +--------------------- |
| 108 | + |
| 109 | +ColorBrewer's "qualitative" colormaps ("Accent", "Dark2", "Paired", |
| 110 | +"Pastel1", "Pastel2", "Set1", "Set2", "Set3") were intended for discrete |
| 111 | +categorical data, with no implication of value, and therefore have been |
| 112 | +converted to ``ListedColormap`` instead of ``LinearSegmentedColormap``, so |
| 113 | +the colors will no longer be interpolated and they can be used for |
| 114 | +choropleths, labeled image features, etc. |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | +Axis offset label now responds to `labelcolor` |
| 119 | +---------------------------------------------- |
| 120 | + |
| 121 | +Axis offset labels are now colored the same as axis tick markers when `labelcolor` is altered. |
| 122 | + |
| 123 | +Improved offset text choice |
| 124 | +--------------------------- |
| 125 | +The default offset-text choice was changed to only use significant digits that |
| 126 | +are common to all ticks (e.g. 1231..1239 -> 1230, instead of 1231), except when |
| 127 | +they straddle a relatively large multiple of a power of ten, in which case that |
| 128 | +multiple is chosen (e.g. 1999..2001->2000). |
| 129 | + |
| 130 | + |
| 131 | +Style parameter blacklist |
| 132 | +------------------------- |
| 133 | + |
| 134 | +In order to prevent unexpected consequences from using a style, style |
| 135 | +files are no longer able to set parameters that affect things |
| 136 | +unrelated to style. These parameters include:: |
| 137 | + |
| 138 | + 'interactive', 'backend', 'backend.qt4', 'webagg.port', |
| 139 | + 'webagg.port_retries', 'webagg.open_in_browser', 'backend_fallback', |
| 140 | + 'toolbar', 'timezone', 'datapath', 'figure.max_open_warning', |
| 141 | + 'savefig.directory', 'tk.window_focus', 'docstring.hardcopy' |
| 142 | + |
| 143 | + |
| 144 | +Change in default font |
| 145 | +---------------------- |
| 146 | + |
| 147 | +The default font used by matplotlib in text has been changed to DejaVu Sans and |
| 148 | +DejaVu Serif for the sans-serif and serif families, respectively. The DejaVu |
| 149 | +font family is based on the previous matplotlib default --Bitstream Vera-- but |
| 150 | +includes a much wider range of characters. |
| 151 | + |
| 152 | +The default mathtext font has been changed from Computer Modern to the DejaVu |
| 153 | +family to maintain consistency with regular text. Two new options for the |
| 154 | +``mathtext.fontset`` configuration parameter have been added: ``dejavusans`` |
| 155 | +(default) and ``dejavuserif``. Both of these options use DejaVu glyphs whenever |
| 156 | +possible and fall back to STIX symbols when a glyph is not found in DejaVu. To |
| 157 | +return to the previous behavior, set the rcParam ``mathtext.fontset`` to ``cm``. |
| 158 | + |
| 159 | + |
| 160 | +Faster text rendering |
| 161 | +--------------------- |
| 162 | + |
| 163 | +Rendering text in the Agg backend is now less fuzzy and about 20% |
| 164 | +faster to draw. |
| 165 | + |
| 166 | + |
| 167 | +Improvements for the Qt figure options editor |
| 168 | +--------------------------------------------- |
| 169 | + |
| 170 | +Various usability improvements were implemented for the Qt figure options |
| 171 | +editor, among which: |
| 172 | + |
| 173 | +- Line style entries are now sorted without duplicates. |
| 174 | +- The colormap and normalization limits can now be set for images. |
| 175 | +- Line edits for floating values now display only as many digits as necessary |
| 176 | + to avoid precision loss. An important bug was also fixed regarding input |
| 177 | + validation using Qt5 and a locale where the decimal separator is ",". |
| 178 | +- The axes selector now uses shorter, more user-friendly names for axes, and |
| 179 | + does not crash if there are no axes. |
| 180 | +- Line and image entries using the default labels ("_lineX", "_imageX") are now |
| 181 | + sorted numerically even when there are more than 10 entries. |
| 182 | + |
| 183 | + |
| 184 | +Improved image support |
| 185 | +---------------------- |
| 186 | + |
| 187 | +Prior to version 2.0, matplotlib resampled images by first applying |
| 188 | +the color map and then resizing the result. Since the resampling was |
| 189 | +performed on the colored image, this introduced colors in the output |
| 190 | +image that didn't actually exist in the color map. Now, images are |
| 191 | +resampled first (and entirely in floating-point, if the input image is |
| 192 | +floating-point), and then the color map is applied. |
| 193 | + |
| 194 | +In order to make this important change, the image handling code was |
| 195 | +almost entirely rewritten. As a side effect, image resampling uses |
| 196 | +less memory and fewer datatype conversions than before. |
| 197 | + |
| 198 | +The experimental private feature where one could "skew" an image by |
| 199 | +setting the private member ``_image_skew_coordinate`` has been |
| 200 | +removed. Instead, images will obey the transform of the axes on which |
| 201 | +they are drawn. |
| 202 | + |
| 203 | +Non-linear scales on image plots |
| 204 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 205 | + |
| 206 | +:func:`imshow` now draws data at the requested points in data space after the |
| 207 | +application of non-linear scales. |
| 208 | + |
| 209 | +The image on the left demonstrates the new, correct behavior. |
| 210 | +The old behavior can be recreated using :func:`pcolormesh` as |
| 211 | +demonstrated on the right. |
| 212 | + |
| 213 | + |
| 214 | +.. plot:: |
| 215 | + |
| 216 | + import numpy as np |
| 217 | + import matplotlib.pyplot as plt |
| 218 | + |
| 219 | + data = np.arange(30).reshape(5, 6) |
| 220 | + x = np.linspace(0, 6, 7) |
| 221 | + y = 10**np.linspace(0, 5, 6) |
| 222 | + X, Y = np.meshgrid(x, y) |
| 223 | + |
| 224 | + fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4)) |
| 225 | + |
| 226 | + ax1.imshow(data, aspect="auto", extent=(0, 6, 1e0, 1e5), interpolation='nearest') |
| 227 | + ax1.set_yscale('log') |
| 228 | + ax1.set_title('Using ax.imshow') |
| 229 | + |
| 230 | + ax2.pcolormesh(x, y, np.flipud(data)) |
| 231 | + ax2.set_yscale('log') |
| 232 | + ax2.set_title('Using ax.pcolormesh') |
| 233 | + ax2.autoscale('tight') |
| 234 | + |
| 235 | + plt.show() |
| 236 | + |
| 237 | + |
| 238 | +This can be understood by analogy to plotting a histogram with linearly spaced bins |
| 239 | +with a logarithmic x-axis. Equal sized bins will be displayed as wider for small |
| 240 | +*x* and narrower for large *x*. |
| 241 | + |
| 242 | + |
| 243 | + |
| 244 | +Support for HiDPI (Retina) displays in the NbAgg and WebAgg backends |
| 245 | +-------------------------------------------------------------------- |
| 246 | + |
| 247 | +The NbAgg and WebAgg backends will now use the full resolution of your |
| 248 | +high-pixel-density display. |
| 249 | + |
| 250 | +Change in the default animation codec |
| 251 | +------------------------------------- |
| 252 | + |
| 253 | +The default animation codec has been changed from ``mpeg4`` to ``h264``, |
| 254 | +which is more efficient. It can be set via the ``animation.codec`` rcParam. |
| 255 | + |
| 256 | +Deprecated support for mencoder in animation |
| 257 | +-------------------------------------------- |
| 258 | + |
| 259 | +The use of mencoder for writing video files with mpl is problematic; |
| 260 | +switching to ffmpeg is strongly advised. All support for mencoder |
| 261 | +will be removed in version 2.2. |
| 262 | + |
| 263 | +Boxplot Zorder Keyword Argument |
| 264 | +------------------------------- |
| 265 | + |
| 266 | +The ``zorder`` parameter now exists for :func:`boxplot`. This allows the zorder |
| 267 | +of a boxplot to be set in the plotting function call. |
| 268 | + |
| 269 | +:: |
| 270 | + |
| 271 | + boxplot(np.arange(10), zorder=10) |
| 272 | + |
| 273 | +Filled ``+`` and ``x`` markers |
| 274 | +------------------------------ |
| 275 | + |
| 276 | +New fillable *plus* and *x* markers have been added. See |
| 277 | +the :mod:`~matplotlib.markers` module and |
| 278 | +:ref:`marker reference <sphx_glr_gallery_lines_bars_and_markers_marker_reference.py>` |
| 279 | +examples. |
| 280 | + |
| 281 | +`rcount` and `ccount` for `plot_surface()` |
| 282 | +------------------------------------------ |
| 283 | + |
| 284 | +As of v2.0, mplot3d's :func:`~mpl_toolkits.mplot3d.axes3d.plot_surface` now |
| 285 | +accepts `rcount` and `ccount` arguments for controlling the sampling of the |
| 286 | +input data for plotting. These arguments specify the maximum number of |
| 287 | +evenly spaced samples to take from the input data. These arguments are |
| 288 | +also the new default sampling method for the function, and is |
| 289 | +considered a style change. |
| 290 | + |
| 291 | +The old `rstride` and `cstride` arguments, which specified the size of the |
| 292 | +evenly spaced samples, become the default when 'classic' mode is invoked, |
| 293 | +and are still available for use. There are no plans for deprecating these |
| 294 | +arguments. |
| 295 | + |
| 296 | +Streamplot Zorder Keyword Argument Changes |
| 297 | +------------------------------------------ |
| 298 | + |
| 299 | +The ``zorder`` parameter for :func:`streamplot` now has default |
| 300 | +value of ``None`` instead of ``2``. If ``None`` is given as ``zorder``, |
| 301 | +:func:`streamplot` has a default ``zorder`` of |
| 302 | +``matplotlib.lines.Line2D.zorder``. |
| 303 | + |
| 304 | +.. _gc_get_hatch_color_wn: |
| 305 | + |
| 306 | +Extension to `matplotlib.backend_bases.GraphicsContextBase` |
| 307 | +----------------------------------------------------------- |
| 308 | + |
| 309 | +To support standardizing hatch behavior across the backends we ship |
| 310 | +the `matplotlib.backend_bases.GraphicsContextBase.get_hatch_color` |
| 311 | +method as added to `matplotlib.backend_bases.GraphicsContextBase`. |
| 312 | +This is only used during the render process in the backends we ship so |
| 313 | +will not break any third-party backends. |
| 314 | + |
| 315 | +If you maintain a third-party backend which extends |
| 316 | +`~matplotlib.backend_bases.GraphicsContextBase` this method is now |
| 317 | +available to you and should be used to color hatch patterns. |
0 commit comments