You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add plot methods statically and add typing to plot tests
* whats-new update
* fix copy-paste typo
* correct plot signatures
* add *some* typing to plot methods
* annotate darray in plot tests
* correct typing of plot returns
* fix plotting overloads
* add correct overloads to dataset_plot
* update whats-new
* rename xr.plot.plot module since it shadows the xr.plot.plot method
* move accessor to its own module
* move DSPlotAccessor to accessor module
* fix DSPlotAccessor import
* add explanation to import statement
* add breaking change to whats-new
* remove unused `rtol` argument from plot
* make most arguments of plotmethods kwargs only
* fix wrong return types
* add breaking kwarg change to whats-new
* support for aspect='auto' or 'equal
* typing support for Dataset FacetGrid
* deprecate positional arguments for all plot methods
* add deprecation to whats-new
* add FacetGrid generic type
* fix mypy 0.981 complaints
* fix index errors in plots
* add overloads to scatter
* deprecate scatter args
* add scatter to accessors and fix docstrings
* undo some breaking changes
* fix the docstrings and some typing
* fix typing of scatter accessor funcs
* align docstrings with signature and complete typing
* add remaining typing
* align more docstrings
* re add ValueError for scatter plots with u, v
* fix whats-new conflict
* fix some typing errors
* more typing fixes
* fix last mypy complaints
* try fixing facetgrid examples
* fix py3.8 problems
* update plotting.rst
* update api
* update plot docstring
* add a tip about yincrease in imshow
* set default for x/yincrease in docstring
* simplify typing
* add deprecation date as comment
* update whats-new to new release
* fix whats-new
Copy file name to clipboardExpand all lines: doc/user-guide/plotting.rst
+34-16Lines changed: 34 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ Matplotlib must be installed before xarray can plot.
27
27
28
28
To use xarray's plotting capabilities with time coordinates containing
29
29
``cftime.datetime`` objects
30
-
`nc-time-axis <https://github.com/SciTools/nc-time-axis>`_ v1.2.0 or later
30
+
`nc-time-axis <https://github.com/SciTools/nc-time-axis>`_ v1.3.0 or later
31
31
needs to be installed.
32
32
33
33
For more extensive plotting applications consider the following projects:
@@ -106,7 +106,13 @@ The simplest way to make a plot is to call the :py:func:`DataArray.plot()` metho
106
106
@savefigplotting_1d_simple.pngwidth=4in
107
107
air1d.plot()
108
108
109
-
Xarray uses the coordinate name along with metadata ``attrs.long_name``, ``attrs.standard_name``, ``DataArray.name`` and ``attrs.units`` (if available) to label the axes. The names ``long_name``, ``standard_name`` and ``units`` are copied from the `CF-conventions spec <https://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/ch03s03.html>`_. When choosing names, the order of precedence is ``long_name``, ``standard_name`` and finally ``DataArray.name``. The y-axis label in the above plot was constructed from the ``long_name`` and ``units`` attributes of ``air1d``.
109
+
Xarray uses the coordinate name along with metadata ``attrs.long_name``,
110
+
``attrs.standard_name``, ``DataArray.name`` and ``attrs.units`` (if available)
111
+
to label the axes.
112
+
The names ``long_name``, ``standard_name`` and ``units`` are copied from the
In addition, one can use ``xscale, yscale`` to set axes scaling; ``xticks, yticks`` to set axes ticks and ``xlim, ylim`` to set axes limits. These accept the same values as the matplotlib methods ``Axes.set_(x,y)scale()``, ``Axes.set_(x,y)ticks()``, ``Axes.set_(x,y)lim()`` respectively.
349
+
In addition, one can use ``xscale, yscale`` to set axes scaling;
350
+
``xticks, yticks`` to set axes ticks and ``xlim, ylim`` to set axes limits.
351
+
These accept the same values as the matplotlib methods ``Axes.set_(x,y)scale()``,
The default method :py:meth:`DataArray.plot` calls :py:func:`xarray.plot.pcolormesh` by default when the data is two-dimensional.
362
+
The default method :py:meth:`DataArray.plot` calls :py:func:`xarray.plot.pcolormesh`
363
+
by default when the data is two-dimensional.
354
364
355
365
.. ipython:: python
356
366
:okwarning:
@@ -585,7 +595,10 @@ Faceting here refers to splitting an array along one or two dimensions and
585
595
plotting each group.
586
596
Xarray's basic plotting is useful for plotting two dimensional arrays. What
587
597
about three or four dimensional arrays? That's where facets become helpful.
588
-
The general approach to plotting here is called “small multiples”, where the same kind of plot is repeated multiple times, and the specific use of small multiples to display the same relationship conditioned on one or more other variables is often called a “trellis plot”.
598
+
The general approach to plotting here is called “small multiples”, where the
599
+
same kind of plot is repeated multiple times, and the specific use of small
600
+
multiples to display the same relationship conditioned on one or more other
601
+
variables is often called a “trellis plot”.
589
602
590
603
Consider the temperature data set. There are 4 observations per day for two
591
604
years which makes for 2920 values along the time dimension.
@@ -670,8 +683,8 @@ Faceted plotting supports other arguments common to xarray 2d plots.
670
683
671
684
@savefigplot_facet_robust.png
672
685
g = hasoutliers.plot.pcolormesh(
673
-
"lon",
674
-
"lat",
686
+
x="lon",
687
+
y="lat",
675
688
col="time",
676
689
col_wrap=3,
677
690
robust=True,
@@ -711,7 +724,7 @@ they have been plotted.
711
724
.. ipython:: python
712
725
:okwarning:
713
726
714
-
g = t.plot.imshow("lon", "lat", col="time", col_wrap=3, robust=True)
727
+
g = t.plot.imshow(x="lon", y="lat", col="time", col_wrap=3, robust=True)
715
728
716
729
for i, ax inenumerate(g.axes.flat):
717
730
ax.set_title("Air Temperature %d"% i)
@@ -727,7 +740,8 @@ they have been plotted.
727
740
axis labels, axis ticks and plot titles. See :py:meth:`~xarray.plot.FacetGrid.set_titles`,
728
741
:py:meth:`~xarray.plot.FacetGrid.set_xlabels`, :py:meth:`~xarray.plot.FacetGrid.set_ylabels` and
729
742
:py:meth:`~xarray.plot.FacetGrid.set_ticks` for more information.
730
-
Plotting functions can be applied to each subset of the data by calling :py:meth:`~xarray.plot.FacetGrid.map_dataarray` or to each subplot by calling :py:meth:`~xarray.plot.FacetGrid.map`.
743
+
Plotting functions can be applied to each subset of the data by calling
744
+
:py:meth:`~xarray.plot.FacetGrid.map_dataarray` or to each subplot by calling :py:meth:`~xarray.plot.FacetGrid.map`.
731
745
732
746
TODO: add an example of using the ``map`` method to plot dataset variables
733
747
(e.g., with ``plt.quiver``).
@@ -777,7 +791,8 @@ Additionally, the boolean kwarg ``add_guide`` can be used to prevent the display
The ``markersize`` kwarg lets you vary the point's size by variable value. You can additionally pass ``size_norm`` to control how the variable's values are mapped to point sizes.
794
+
The ``markersize`` kwarg lets you vary the point's size by variable value.
795
+
You can additionally pass ``size_norm`` to control how the variable's values are mapped to point sizes.
For more advanced scatter plots, we recommend converting the relevant data variables to a pandas DataFrame and using the extensive plotting capabilities of ``seaborn``.
812
+
For more advanced scatter plots, we recommend converting the relevant data variables
813
+
to a pandas DataFrame and using the extensive plotting capabilities of ``seaborn``.
798
814
799
815
Quiver
800
816
~~~~~~
@@ -816,7 +832,8 @@ where ``u`` and ``v`` denote the x and y direction components of the arrow vecto
``scale`` is required for faceted quiver plots. The scale determines the number of data units per arrow length unit, i.e. a smaller scale parameter makes the arrow longer.
835
+
``scale`` is required for faceted quiver plots.
836
+
The scale determines the number of data units per arrow length unit, i.e. a smaller scale parameter makes the arrow longer.
820
837
821
838
Streamplot
822
839
~~~~~~~~~~
@@ -830,7 +847,8 @@ Visualizing vector fields is also supported with streamline plots:
0 commit comments