pygmt.Figure.scatter

Figure.scatter(x, y, symbol, size, fill=None, intensity=None, transparency=None, cmap=None, pen=None, no_clip=False, perspective=None)

Plot scatter points.

It can plot data points with constant or varying symbols, sizes, colors, transparencies, and intensities. The parameters symbol, size, fill, intensity, and transparency can be a single scalar value or a sequence of values with the same length as the number of data points. If a single value is given, it is used for all data points. If a sequence is given, different values are used for different data points.

Parameters:
  • x – The data coordinates.

  • y – The data coordinates.

  • symbol (str | Sequence[str]) –

    The symbol(s) to use. Valid symbols are:

    • -: X-dash (-)

    • +: Plus

    • a: Star

    • c: Circle

    • d: Diamond

    • g: Octagon

    • h: Hexagon

    • i: Inverted triangle

    • n: Pentagon

    • s: Square

    • t: Triangle

    • x: Cross

    • y: Y-dash (|)

  • size (float | str | Sequence[float | str]) – The size(s) of the points.

  • fill (str | Sequence[float] | None, default: None) – Set color or pattern for filling symbols [Default is no fill]. If a sequence of values is given, cmap must be specified.

  • intensity (float | Sequence[float] | None, default: None) – The intensity(ies) of the points.

  • transparency (float | Sequence[float] | None, default: None) – The transparency(ies) of the points.

  • cmap (str | bool | None, default: None) – The colormap to map scalar values in fill to colors. In this case, fill must be a sequence of values.

  • pen (str | float | None, default: None) – The pen property of the symbol outline.

  • no_clip (bool, default: False) – If True, do not clip the points that fall outside the frame boundaries.

  • perspective (list or str) – [x|y|z]azim[/elev[/zlevel]][+wlon0/lat0[/z0]][+vx0/y0]. Select perspective view and set the azimuth and elevation angle of the viewpoint [Default is [180, 90]]. Full documentation is at https://docs.generic-mapping-tools.org/6.5/gmt.html#perspective-full.

Examples

Plot three points with the same symbol and size.

>>> import pygmt
>>> fig = pygmt.Figure()
>>> fig.basemap(region=[0, 3, 0, 3], projection="X10c/5c", frame=True)
>>> fig.scatter(x=[0, 1, 2], y=[0, 1, 2], symbol="c", size=0.3, fill="red")
>>> fig.show()

Plot three points with different sizes and transparencies.

>>> fig = pygmt.Figure()
>>> fig.basemap(region=[0, 3, 0, 3], projection="X10c/5c", frame=True)
>>> fig.scatter(
...     x=[0, 1, 2],
...     y=[0, 1, 2],
...     symbol="c",
...     size=[0.5, 0.3, 0.2],
...     fill="blue",
...     transparency=[50, 70, 90],
... )
>>> fig.show()