1API Changes for 3.0.0 2===================== 3 4Drop support for python 2 5------------------------- 6 7Matplotlib 3 only supports python 3.5 and higher. 8 9 10Changes to backend loading 11-------------------------- 12 13Failure to load backend modules (``macosx`` on non-framework builds and 14``gtk3`` when running headless) now raises `ImportError` (instead of 15`RuntimeError` and `TypeError`, respectively). 16 17Third-party backends that integrate with an interactive framework are now 18encouraged to define the ``required_interactive_framework`` global value to one 19of the following values: "qt5", "qt4", "gtk3", "wx", "tk", or "macosx". This 20information will be used to determine whether it is possible to switch from a 21backend to another (specifically, whether they use the same interactive 22framework). 23 24 25 26`.Axes.hist2d` now uses `~.Axes.pcolormesh` instead of `~.Axes.pcolorfast` 27-------------------------------------------------------------------------- 28 29`.Axes.hist2d` now uses `~.Axes.pcolormesh` instead of `~.Axes.pcolorfast`, 30which will improve the handling of log-axes. Note that the 31returned *image* now is of type `~.matplotlib.collections.QuadMesh` 32instead of `~.matplotlib.image.AxesImage`. 33 34`.matplotlib.axes.Axes.get_tightbbox` now includes all artists 35-------------------------------------------------------------- 36 37For Matplotlib 3.0, *all* artists are now included in the bounding box 38returned by `.matplotlib.axes.Axes.get_tightbbox`. 39 40`.matplotlib.axes.Axes.get_tightbbox` adds a new kwarg ``bbox_extra_artists`` 41to manually specify the list of artists on the axes to include in the 42tight bounding box calculation. 43 44Layout tools like `.Figure.tight_layout`, ``constrained_layout``, 45and ``fig.savefig('fname.png', bbox_inches="tight")`` use 46`.matplotlib.axes.Axes.get_tightbbox` to determine the bounds of each axes on 47a figure and adjust spacing between axes. 48 49In Matplotlib 2.2 ``get_tightbbox`` started to include legends made on the 50axes, but still excluded some other artists, like text that may overspill an 51axes. This has been expanded to include *all* artists. 52 53This new default may be overridden in either of three ways: 54 551. Make the artist to be excluded a child of the figure, not the axes. E.g., 56 call ``fig.legend()`` instead of ``ax.legend()`` (perhaps using 57 `~.matplotlib.axes.Axes.get_legend_handles_labels` to gather handles and 58 labels from the parent axes). 592. If the artist is a child of the axes, set the artist property 60 ``artist.set_in_layout(False)``. 613. Manually specify a list of artists in the new kwarg ``bbox_extra_artists``. 62 63 64`.Text.set_text` with string argument ``None`` sets string to empty 65------------------------------------------------------------------- 66 67`.Text.set_text` when passed a string value of ``None`` would set the 68string to ``"None"``, so subsequent calls to `.Text.get_text` would return 69the ambiguous ``"None"`` string. 70 71This change sets text objects passed ``None`` to have empty strings, so that 72`.Text.get_text` returns an empty string. 73 74 75 76 77``Axes3D.get_xlim``, ``get_ylim`` and ``get_zlim`` now return a tuple 78--------------------------------------------------------------------- 79 80They previously returned an array. Returning a tuple is consistent with the 81behavior for 2D axes. 82 83 84 85 86``font_manager.list_fonts`` now follows the platform's casefolding semantics 87---------------------------------------------------------------------------- 88 89i.e., it behaves case-insensitively on Windows only. 90 91 92``bar`` / ``barh`` no longer accepts ``left`` / ``bottom`` as first named argument 93---------------------------------------------------------------------------------- 94 95These arguments were renamed in 2.0 to ``x`` / ``y`` following the change of the 96default alignment from ``edge`` to ``center``. 97 98 99Different exception types for undocumented options 100-------------------------------------------------- 101 102- Passing ``style='comma'`` to :meth:`~matplotlib.axes.Axes.ticklabel_format` 103 was never supported. It now raises ``ValueError`` like all other 104 unsupported styles, rather than ``NotImplementedError``. 105 106- Passing the undocumented ``xmin`` or ``xmax`` arguments to 107 :meth:`~matplotlib.axes.Axes.set_xlim` would silently override the ``left`` 108 and ``right`` arguments. :meth:`~matplotlib.axes.Axes.set_ylim` and the 109 3D equivalents (e.g. `~.Axes3D.set_zlim3d`) had a 110 corresponding problem. 111 A ``TypeError`` will be raised if they would override the earlier 112 limit arguments. In 3.0 these were kwargs were deprecated, but in 3.1 113 the deprecation was undone. 114 115 116Improved call signature for ``Axes.margins`` 117-------------------------------------------- 118 119`.Axes.margins` and `.Axes3D.margins` 120no longer accept arbitrary keywords. ``TypeError`` will therefore be raised 121if unknown kwargs are passed; previously they would be silently ignored. 122 123If too many positional arguments are passed, ``TypeError`` will be raised 124instead of ``ValueError``, for consistency with other call-signature violations. 125 126`.Axes3D.margins` now raises ``TypeError`` instead of emitting a deprecation 127warning if only two positional arguments are passed. To supply only ``x`` and 128``y`` margins, use keyword arguments. 129 130 131 132Explicit arguments instead of \*args, \*\*kwargs 133------------------------------------------------ 134 135:PEP:`3102` describes keyword-only arguments, which allow Matplotlib 136to provide explicit call signatures - where we previously used 137``*args, **kwargs`` and ``kwargs.pop``, we can now expose named 138arguments. In some places, unknown kwargs were previously ignored but 139now raise ``TypeError`` because ``**kwargs`` has been removed. 140 141- :meth:`matplotlib.axes.Axes.stem` no longer accepts unknown keywords, 142 and raises ``TypeError`` instead of emitting a deprecation. 143- :meth:`matplotlib.axes.Axes.stem` now raises TypeError when passed 144 unhandled positional arguments. If two or more arguments are passed 145 (ie X, Y, [linefmt], ...) and Y cannot be cast to an array, an error 146 will be raised instead of treating X as Y and Y as linefmt. 147- `mpl_toolkits.axes_grid1.axes_divider.SubplotDivider` raises 148 ``TypeError`` instead of ``Exception`` when passed unknown kwargs. 149 150 151 152Cleanup decorators and test classes no longer destroy warnings filter on exit 153----------------------------------------------------------------------------- 154 155The decorators and classes in matplotlib.testing.decorators no longer 156destroy the warnings filter on exit. Instead, they restore the warnings 157filter that existed before the test started using ``warnings.catch_warnings``. 158 159 160Non-interactive FigureManager classes are now aliases of FigureManagerBase 161-------------------------------------------------------------------------- 162 163The ``FigureManagerPdf``, ``FigureManagerPS``, and ``FigureManagerSVG`` classes, 164which were previously empty subclasses of `.FigureManagerBase` (i.e., not 165adding or overriding any attribute or method), are now direct aliases for 166`.FigureManagerBase`. 167 168 169Change to the output of `.image.thumbnail` 170------------------------------------------ 171 172When called with ``preview=False``, `.image.thumbnail` previously returned an 173figure whose canvas class was set according to the output file extension. It 174now returns a figure whose canvas class is the base `.FigureCanvasBase` (and 175relies on `.FigureCanvasBase.print_figure`) to handle the canvas switching 176properly). 177 178As a side effect of this change, `.image.thumbnail` now also supports .ps, .eps, 179and .svgz output. 180 181 182 183`.FuncAnimation` now draws artists according to their zorder when blitting 184-------------------------------------------------------------------------- 185 186`.FuncAnimation` now draws artists returned by the user- 187function according to their zorder when using blitting, 188instead of using the order in which they are being passed. 189However, note that only zorder of passed artists will be 190respected, as they are drawn on top of any existing artists 191(see `#11369 <https://github.com/matplotlib/matplotlib/issues/11369>`_). 192 193 194Contour color autoscaling improvements 195-------------------------------------- 196 197Selection of contour levels is now the same for contour and 198contourf; previously, for contour, levels outside the data range were 199deleted. (Exception: if no contour levels are found within the 200data range, the `levels` attribute is replaced with a list holding 201only the minimum of the data range.) 202 203When contour is called with levels specified as a target number rather 204than a list, and the 'extend' kwarg is used, the levels are now chosen 205such that some data typically will fall in the extended range. 206 207When contour is called with a `.LogNorm` or a `.LogLocator`, it will now 208select colors using the geometric mean rather than the arithmetic mean 209of the contour levels. 210 211 212Streamplot last row and column fixed 213------------------------------------ 214 215A bug was fixed where the last row and column of data in 216`~.Axes.streamplot` were being dropped. 217 218 219Changed default `.AutoDateLocator` kwarg *interval_multiples* to ``True`` 220------------------------------------------------------------------------- 221 222The default value of the tick locator for dates, `.dates.AutoDateLocator` 223kwarg *interval_multiples* was set to ``False`` which leads to not-nice 224looking automatic ticks in many instances. The much nicer 225``interval_multiples=True`` is the new default. See below to get the 226old behavior back: 227 228 .. plot:: 229 230 import matplotlib.pyplot as plt 231 import datetime 232 import matplotlib.dates as mdates 233 234 t0 = datetime.datetime(2009, 8, 20, 1, 10, 12) 235 tf = datetime.datetime(2009, 8, 20, 1, 42, 11) 236 237 238 fig, axs = plt.subplots(1, 2, constrained_layout=True) 239 ax = axs[0] 240 ax.axhspan(t0, tf, facecolor="blue", alpha=0.25) 241 ax.set_ylim(t0 - datetime.timedelta(minutes=3), 242 tf + datetime.timedelta(minutes=3)) 243 ax.set_title('NEW DEFAULT') 244 245 ax = axs[1] 246 ax.axhspan(t0, tf, facecolor="blue", alpha=0.25) 247 ax.set_ylim(t0 - datetime.timedelta(minutes=3), 248 tf + datetime.timedelta(minutes=3)) 249 # old behavior 250 locator = mdates.AutoDateLocator(interval_multiples=False, ) 251 ax.yaxis.set_major_locator(locator) 252 ax.yaxis.set_major_formatter(mdates.AutoDateFormatter(locator)) 253 254 ax.set_title('OLD') 255 plt.show() 256 257 258`.Axes.get_position` now returns actual position if aspect changed 259------------------------------------------------------------------ 260 261`.Axes.get_position` used to return the original position unless a 262draw had been triggered or `.Axes.apply_aspect` had been called, even 263if the kwarg *original* was set to ``False``. Now `.Axes.apply_aspect` 264is called so ``ax.get_position()`` will return the new modified position. 265To get the old behavior use ``ax.get_position(original=True)``. 266 267 268The ticks for colorbar now adjust for the size of the colorbar 269-------------------------------------------------------------- 270 271Colorbar ticks now adjust for the size of the colorbar if the 272colorbar is made from a mappable that is not a contour or 273doesn't have a BoundaryNorm, or boundaries are not specified. 274If boundaries, etc are specified, the colorbar maintains the 275original behavior. 276 277 278Colorbar for log-scaled hexbin 279------------------------------ 280 281When using `~.Axes.hexbin` and plotting with a logarithmic color scale, the colorbar 282ticks are now correctly log scaled. Previously the tick values were linear 283scaled log(number of counts). 284 285PGF backend now explicitly makes black text black 286------------------------------------------------- 287 288Previous behavior with the pgf backend was for text specified as black to 289actually be the default color of whatever was rendering the pgf file (which was 290of course usually black). The new behavior is that black text is black, 291regardless of the default color. However, this means that there is no way to 292fall back on the default color of the renderer. 293 294 295Blacklisted rcparams no longer updated by `~matplotlib.rcdefaults`, `~matplotlib.rc_file_defaults`, `~matplotlib.rc_file` 296------------------------------------------------------------------------------------------------------------------------- 297 298The rc modifier functions `~matplotlib.rcdefaults`, 299`~matplotlib.rc_file_defaults` and `~matplotlib.rc_file` 300now ignore rcParams in the `matplotlib.style.core.STYLE_BLACKLIST` set. In 301particular, this prevents the ``backend`` and ``interactive`` rcParams from 302being incorrectly modified by these functions. 303 304 305 306`.CallbackRegistry` now stores callbacks using stdlib's `weakref.WeakMethod`\s 307------------------------------------------------------------------------------ 308 309In particular, this implies that ``CallbackRegistry.callbacks[signal]`` is now 310a mapping of callback ids to `weakref.WeakMethod`\s (i.e., they need to be first called 311with no arguments to retrieve the method itself). 312 313 314Changes regarding the text.latex.unicode rcParam 315------------------------------------------------ 316 317The rcParam now defaults to True and is deprecated (i.e., in future versions 318of Matplotlib, unicode input will always be supported). 319 320Moreover, the underlying implementation now uses ``\usepackage[utf8]{inputenc}`` 321instead of ``\usepackage{ucs}\usepackage[utf8x]{inputenc}``. 322 323 324Return type of ArtistInspector.get_aliases changed 325-------------------------------------------------- 326 327`ArtistInspector.get_aliases` previously returned the set of aliases as 328``{fullname: {alias1: None, alias2: None, ...}}``. The dict-to-None mapping 329was used to simulate a set in earlier versions of Python. It has now been 330replaced by a set, i.e. ``{fullname: {alias1, alias2, ...}}``. 331 332This value is also stored in `.ArtistInspector.aliasd`, which has likewise 333changed. 334 335 336Removed ``pytz`` as a dependency 337-------------------------------- 338 339Since ``dateutil`` and ``pytz`` both provide time zones, and 340matplotlib already depends on ``dateutil``, matplotlib will now use 341``dateutil`` time zones internally and drop the redundant dependency 342on ``pytz``. While ``dateutil`` time zones are preferred (and 343currently recommended in the Python documentation), the explicit use 344of ``pytz`` zones is still supported. 345 346Deprecations 347------------ 348 349Modules 350``````` 351The following modules are deprecated: 352 353- ``matplotlib.compat.subprocess``. This was a python 2 workaround, but all 354 the functionality can now be found in the python 3 standard library 355 :mod:`subprocess`. 356- ``matplotlib.backends.wx_compat``. Python 3 is only compatible with 357 wxPython 4, so support for wxPython 3 or earlier can be dropped. 358 359Classes, methods, functions, and attributes 360``````````````````````````````````````````` 361 362The following classes, methods, functions, and attributes are deprecated: 363 364- ``RcParams.msg_depr``, ``RcParams.msg_depr_ignore``, 365 ``RcParams.msg_depr_set``, ``RcParams.msg_obsolete``, 366 ``RcParams.msg_backend_obsolete`` 367- ``afm.parse_afm`` 368- ``backend_pdf.PdfFile.texFontMap`` 369- ``backend_pgf.get_texcommand`` 370- ``backend_ps.get_bbox`` 371- ``backend_qt5.FigureCanvasQT.keyAutoRepeat`` (directly check 372 ``event.guiEvent.isAutoRepeat()`` in the event handler to decide whether to 373 handle autorepeated key presses). 374- ``backend_qt5.error_msg_qt``, ``backend_qt5.exception_handler`` 375- ``backend_wx.FigureCanvasWx.macros`` 376- ``backends.pylab_setup`` 377- ``cbook.GetRealpathAndStat``, ``cbook.Locked`` 378- ``cbook.is_numlike`` (use ``isinstance(..., numbers.Number)`` instead), 379 ``cbook.listFiles``, ``cbook.unicode_safe`` 380- ``container.Container.set_remove_method``, 381- ``contour.ContourLabeler.cl``, ``.cl_xy``, and ``.cl_cvalues`` 382- ``dates.DateFormatter.strftime_pre_1900``, ``dates.DateFormatter.strftime`` 383- ``font_manager.TempCache`` 384- ``image._ImageBase.iterpnames``, use the ``interpolation_names`` property 385 instead. (this affects classes that inherit from ``_ImageBase`` including 386 `.FigureImage`, `.BboxImage`, and `.AxesImage`) 387- ``mathtext.unichr_safe`` (use ``chr`` instead) 388- ``patches.Polygon.xy`` 389- ``table.Table.get_child_artists`` (use ``get_children`` instead) 390- ``testing.compare.ImageComparisonTest``, ``testing.compare.compare_float`` 391- ``testing.decorators.CleanupTest``, 392 ``testing.decorators.skip_if_command_unavailable`` 393- ``FigureCanvasQT.keyAutoRepeat`` (directly check 394 ``event.guiEvent.isAutoRepeat()`` in the event handler to decide whether to 395 handle autorepeated key presses) 396- ``FigureCanvasWx.macros`` 397- ``_ImageBase.iterpnames``, use the ``interpolation_names`` property instead. 398 (this affects classes that inherit from ``_ImageBase`` including 399 `.FigureImage`, `.BboxImage`, and `.AxesImage`) 400- ``patches.Polygon.xy`` 401- ``texmanager.dvipng_hack_alpha`` 402- ``text.Annotation.arrow`` 403- ``Legend.draggable()``, in favor of `.Legend.set_draggable()` 404 (``Legend.draggable`` may be reintroduced as a property in future releases) 405- ``textpath.TextToPath.tex_font_map`` 406- ``matplotlib.cbook.deprecation.mplDeprecation`` will be removed 407 in future versions. It is just an alias for 408 ``matplotlib.cbook.deprecation.MatplotlibDeprecationWarning``. Please 409 use ``matplotlib.cbook.MatplotlibDeprecationWarning`` directly if necessary. 410- The ``matplotlib.cbook.Bunch`` class has been deprecated. Instead, use 411 `types.SimpleNamespace` from the standard library which provides the same 412 functionality. 413- ``Axes.mouseover_set`` is now a frozenset, and deprecated. Directly 414 manipulate the artist's ``.mouseover`` attribute to change their mouseover 415 status. 416 417The following keyword arguments are deprecated: 418 419- passing ``verts`` to ``Axes.scatter`` (use ``marker`` instead) 420- passing ``obj_type`` to ``cbook.deprecated`` 421 422The following call signatures are deprecated: 423 424- passing a ``wx.EvtHandler`` as first argument to ``backend_wx.TimerWx`` 425 426 427rcParams 428```````` 429 430The following rcParams are deprecated: 431 432- ``examples.directory`` (use ``datapath`` instead) 433- ``pgf.debug`` (the pgf backend relies on logging) 434- ``text.latex.unicode`` (always True now) 435 436 437marker styles 438````````````` 439- Using ``(n, 3)`` as marker style to specify a circle marker is deprecated. Use 440 ``"o"`` instead. 441- Using ``([(x0, y0), (x1, y1), ...], 0)`` as marker style to specify a custom 442 marker path is deprecated. Use ``[(x0, y0), (x1, y1), ...]`` instead. 443 444 445Deprecation of ``LocatableAxes`` in toolkits 446```````````````````````````````````````````` 447 448The ``LocatableAxes`` classes in toolkits have been deprecated. The base `~.axes.Axes` 449classes provide the same functionality to all subclasses, thus these mixins are 450no longer necessary. Related functions have also been deprecated. Specifically: 451 452* ``mpl_toolkits.axes_grid1.axes_divider.LocatableAxesBase``: no specific 453 replacement; use any other ``Axes``-derived class directly instead. 454* ``mpl_toolkits.axes_grid1.axes_divider.locatable_axes_factory``: no specific 455 replacement; use any other ``Axes``-derived class directly instead. 456* ``mpl_toolkits.axes_grid1.axes_divider.Axes``: use 457 `mpl_toolkits.axes_grid1.mpl_axes.Axes` directly. 458* ``mpl_toolkits.axes_grid1.axes_divider.LocatableAxes``: use 459 `mpl_toolkits.axes_grid1.mpl_axes.Axes` directly. 460* ``mpl_toolkits.axisartist.axes_divider.Axes``: use 461 `mpl_toolkits.axisartist.axislines.Axes` directly. 462* ``mpl_toolkits.axisartist.axes_divider.LocatableAxes``: use 463 `mpl_toolkits.axisartist.axislines.Axes` directly. 464 465Removals 466-------- 467 468Hold machinery 469`````````````` 470 471Setting or unsetting ``hold`` (:ref:`deprecated in version 2.0<v200_deprecate_hold>`) has now 472been completely removed. Matplotlib now always behaves as if ``hold=True``. 473To clear an axes you can manually use :meth:`~.axes.Axes.cla()`, 474or to clear an entire figure use :meth:`~.figure.Figure.clf()`. 475 476 477Removal of deprecated backends 478`````````````````````````````` 479 480Deprecated backends have been removed: 481 482- GTKAgg 483- GTKCairo 484- GTK 485- GDK 486 487 488Deprecated APIs 489``````````````` 490 491The following deprecated API elements have been removed: 492 493- The deprecated methods ``knownfailureif`` and ``remove_text`` have been removed 494 from :mod:`matplotlib.testing.decorators`. 495- The entire contents of ``testing.noseclasses`` have also been removed. 496- ``matplotlib.checkdep_tex``, ``matplotlib.checkdep_xmllint`` 497- ``backend_bases.IdleEvent`` 498- ``cbook.converter``, ``cbook.tostr``, ``cbook.todatetime``, ``cbook.todate``, 499 ``cbook.tofloat``, ``cbook.toint``, ``cbook.unique``, 500 ``cbook.is_string_like``, ``cbook.is_sequence_of_strings``, 501 ``cbook.is_scalar``, ``cbook.soundex``, ``cbook.dict_delall``, 502 ``cbook.get_split_ind``, ``cbook.wrap``, ``cbook.get_recursive_filelist``, 503 ``cbook.pieces``, ``cbook.exception_to_str``, ``cbook.allequal``, 504 ``cbook.alltrue``, ``cbook.onetrue``, ``cbook.allpairs``, ``cbook.finddir``, 505 ``cbook.reverse_dict``, ``cbook.restrict_dict``, ``cbook.issubclass_safe``, 506 ``cbook.recursive_remove``, ``cbook.unmasked_index_ranges``, 507 ``cbook.Null``, ``cbook.RingBuffer``, ``cbook.Sorter``, ``cbook.Xlator``, 508- ``font_manager.weight_as_number``, ``font_manager.ttfdict_to_fnames`` 509- ``pyplot.colors``, ``pyplot.spectral`` 510- ``rcsetup.validate_negative_linestyle``, 511 ``rcsetup.validate_negative_linestyle_legacy``, 512- ``testing.compare.verifiers``, ``testing.compare.verify`` 513- ``testing.decorators.knownfailureif``, 514 ``testing.decorators.ImageComparisonTest.remove_text`` 515- ``tests.assert_str_equal``, ``tests.test_tinypages.file_same`` 516- ``texmanager.dvipng_hack_alpha``, 517- ``_AxesBase.axesPatch``, ``_AxesBase.set_color_cycle``, 518 ``_AxesBase.get_cursor_props``, ``_AxesBase.set_cursor_props`` 519- ``_ImageBase.iterpnames`` 520- ``FigureCanvasBase.start_event_loop_default``; 521- ``FigureCanvasBase.stop_event_loop_default``; 522- ``Figure.figurePatch``, 523- ``FigureCanvasBase.dynamic_update``, ``FigureCanvasBase.idle_event``, 524 ``FigureCanvasBase.get_linestyle``, ``FigureCanvasBase.set_linestyle`` 525- ``FigureCanvasQTAggBase`` 526- ``FigureCanvasQTAgg.blitbox`` 527- ``FigureCanvasTk.show`` (alternative: ``FigureCanvasTk.draw``) 528- ``FigureManagerTkAgg`` (alternative: ``FigureManagerTk``) 529- ``NavigationToolbar2TkAgg`` (alternative: ``NavigationToolbar2Tk``) 530- ``backend_wxagg.Toolbar`` (alternative: ``backend_wxagg.NavigationToolbar2WxAgg``) 531- ``RendererAgg.debug()`` 532- passing non-numbers to ``EngFormatter.format_eng`` 533- passing ``frac`` to ``PolarAxes.set_theta_grids`` 534- any mention of idle events 535 536The following API elements have been removed: 537 538- ``backend_cairo.HAS_CAIRO_CFFI`` 539- ``sphinxext.sphinx_version`` 540 541 542Proprietary sphinx directives 543````````````````````````````` 544 545The matplotlib documentation used the proprietary sphinx directives 546``.. htmlonly::``, and ``.. latexonly::``. These have been replaced with the 547standard sphinx directives ``.. only:: html`` and ``.. only:: latex``. This 548change will not affect any users. Only downstream package maintainers, who 549have used the proprietary directives in their docs, will have to switch to the 550sphinx directives. 551 552 553lib/mpl_examples symlink 554```````````````````````` 555 556The symlink from lib/mpl_examples to ../examples has been removed. 557This is not installed as an importable package and should not affect 558end users, however this may require down-stream packagers to adjust. 559The content is still available top-level examples directory. 560