Skip to content

The color parameter of plot and plot3d methods can be 1d array #1075

@core-man

Description

@core-man

Description of the problem

We need to update the documentation for the color parameter in plot and plot3d because color can also be 1d array (originally posted in #1065 (comment)).


See the description of the color parameter of plot:

color (str) – Select color or pattern for filling of symbols or polygons. Default is no fill.

See the description of the color parameter of plot3d:

color (str) – Select color or pattern for filling of symbols or polygons. Default is no fill.


However, color can also be a 1d array just like the sizes parameter when we use x/y parameters for in the plot and plot3d methods. See the last example in Plotting data points. We can set color=data.depth_km and data.depth_km is a 1d array.

import pygmt
data = pygmt.datasets.load_japan_quakes()
region = [
    data.longitude.min() - 1,
    data.longitude.max() + 1,
    data.latitude.min() - 1,
    data.latitude.max() + 1,
]
print(region)
print(data.head())

fig = pygmt.Figure()
fig.basemap(region=region, projection="M15c", frame=True)
fig.coast(land="black", water="skyblue")
pygmt.makecpt(cmap="viridis", series=[data.depth_km.min(), data.depth_km.max()])
fig.plot(
    x=data.longitude,
    y=data.latitude,
    sizes=0.02 * 2 ** data.magnitude,
    color=data.depth_km,
    cmap=True,
    style="cc",
    pen="black",
)
fig.colorbar(frame='af+l"Depth (km)"')
fig.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomersscipy-sprintThings to work on during the SciPy sprint!

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions