Scatter plot#

[1]:
import plopp as pp
import scipp as sc

Simple scatter plot#

[2]:
a = pp.data.scatter()
pp.scatter(a)
[2]:
../../_images/user-guide_plot-types_scatter-plot_3_0.svg

Changing the style of the points can be done via

[3]:
pp.scatter(a, color='r', marker='P')
[3]:
../../_images/user-guide_plot-types_scatter-plot_5_0.svg

Selecting which coordinates to use#

By default, the scatter plot will search for and use the 'x' coordinate in the input as abscissa values, and the 'y' coordinate as ordinate values.

This can however be customized by telling it which ones to use:

[4]:
a.coords['4x'] = a.coords['x'] * 4
print(a.coords.keys())

pp.scatter(a, x='4x', y='z', aspect='equal')
<scipp.Dict.keys {position, x, y, z, 4x}>
[4]:
../../_images/user-guide_plot-types_scatter-plot_7_1.svg

Scatter plot with multiple inputs#

[5]:
a = pp.data.scatter()
b = pp.data.scatter(seed=2) * 10.0
b.coords['x'] += sc.scalar(50.0, unit='m')

pp.scatter({'a': a, 'b': b})
[5]:
../../_images/user-guide_plot-types_scatter-plot_9_0.svg

Changing the style can be controlled for each input:

[6]:
pp.scatter({'a': a, 'b': b},
          color={'a': 'k', 'b': 'g'})
[6]:
../../_images/user-guide_plot-types_scatter-plot_11_0.svg

Scatter plot with a colorbar#

Requesting a colorbar when calling the scatter function will use the values inside the data array as colors:

[7]:
pp.scatter(a, cbar=True)
[7]:
../../_images/user-guide_plot-types_scatter-plot_13_0.svg

Scatter plot with sizes#

[8]:
a = pp.data.scatter()
a.coords['s'] = sc.abs(a.coords['x']) * 5

pp.scatter(a, size='s', cbar=True, legend=False)
[8]:
../../_images/user-guide_plot-types_scatter-plot_15_0.svg

Scatter plot with masks#

[9]:
a = pp.data.scatter()
a.masks['m'] = a.coords['x'] > sc.scalar(10, unit='m')
pp.scatter(a)
[9]:
../../_images/user-guide_plot-types_scatter-plot_17_0.svg