@@ -756,14 +756,32 @@ Consider this dataset
756756
757757.. ipython :: python
758758
759- ds = xr.tutorial.scatter_example_dataset()
759+ ds = xr.tutorial.scatter_example_dataset(seed = 42 )
760760 ds
761761
762762
763763 Scatter
764764~~~~~~~
765765
766- Suppose we want to scatter ``A `` against ``B ``
766+ Let's plot the ``A `` DataArray as a function of the ``y `` coord
767+
768+ .. ipython :: python
769+ :okwarning:
770+
771+ ds.A
772+
773+ @savefig da_A_y.png
774+ ds.A.plot.scatter(x = " y" )
775+
776+ Same plot can be displayed using the dataset:
777+
778+ .. ipython :: python
779+ :okwarning:
780+
781+ @savefig ds_A_y.png
782+ ds.plot.scatter(x = " y" , y = " A" )
783+
784+ Now suppose we want to scatter the ``A `` DataArray against the ``B `` DataArray
767785
768786.. ipython :: python
769787 :okwarning:
@@ -779,17 +797,19 @@ The ``hue`` kwarg lets you vary the color by variable value
779797 @savefig ds_hue_scatter.png
780798 ds.plot.scatter(x = " A" , y = " B" , hue = " w" )
781799
782- When ``hue `` is specified, a colorbar is added for numeric ``hue `` DataArrays by
783- default and a legend is added for non-numeric ``hue `` DataArrays (as above).
784- You can force a legend instead of a colorbar by setting ``hue_style='discrete' ``.
785- Additionally, the boolean kwarg ``add_guide `` can be used to prevent the display of a legend or colorbar (as appropriate).
800+ You can force a legend instead of a colorbar by setting ``add_legend=True, add_colorbar=False ``.
786801
787802.. ipython :: python
788803 :okwarning:
789804
790- ds = ds.assign(w = [1 , 2 , 3 , 5 ])
791805 @savefig ds_discrete_legend_hue_scatter.png
792- ds.plot.scatter(x = " A" , y = " B" , hue = " w" , hue_style = " discrete" )
806+ ds.plot.scatter(x = " A" , y = " B" , hue = " w" , add_legend = True , add_colorbar = False )
807+
808+ .. ipython :: python
809+ :okwarning:
810+
811+ @savefig ds_discrete_colorbar_hue_scatter.png
812+ ds.plot.scatter(x = " A" , y = " B" , hue = " w" , add_legend = False , add_colorbar = True )
793813
794814 The ``markersize `` kwarg lets you vary the point's size by variable value.
795815You can additionally pass ``size_norm `` to control how the variable's values are mapped to point sizes.
@@ -798,16 +818,31 @@ You can additionally pass ``size_norm`` to control how the variable's values are
798818 :okwarning:
799819
800820 @savefig ds_hue_size_scatter.png
801- ds.plot.scatter(x = " A" , y = " B" , hue = " z" , hue_style = " discrete" , markersize = " z" )
821+ ds.plot.scatter(x = " A" , y = " B" , hue = " y" , markersize = " z" )
822+
823+ The ``z `` kwarg lets you plot the data along the z-axis as well.
824+
825+ .. ipython :: python
826+ :okwarning:
827+
828+ @savefig ds_hue_size_scatter_z.png
829+ ds.plot.scatter(x = " A" , y = " B" , z = " z" , hue = " y" , markersize = " x" )
802830
803831 Faceting is also possible
804832
805833.. ipython :: python
806834 :okwarning:
807835
808836 @savefig ds_facet_scatter.png
809- ds.plot.scatter(x = " A" , y = " B" , col = " x" , row = " z" , hue = " w" , hue_style = " discrete" )
837+ ds.plot.scatter(x = " A" , y = " B" , hue = " y" , markersize = " x" , row = " x" , col = " w" )
838+
839+ And adding the z-axis
840+
841+ .. ipython :: python
842+ :okwarning:
810843
844+ @savefig ds_facet_scatter_z.png
845+ ds.plot.scatter(x = " A" , y = " B" , z = " z" , hue = " y" , markersize = " x" , row = " x" , col = " w" )
811846
812847 For more advanced scatter plots, we recommend converting the relevant data variables
813848to a pandas DataFrame and using the extensive plotting capabilities of ``seaborn ``.
0 commit comments