Repository navigation
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
I feel the basic tutorial "Plotting lines" can be improved by covering different ways of connecting data points (please see the code examples and images below).
- Include the +s modifier of the
penparameter - Include the
straight_lineparameter - The second part "Change line attributes" is actually quite similar to the Gallery example "Line styles". Both cover adjusting the
penattributes width,color,style. Maybe we can summarise these three plots into one? And decide for using the same term, i.e. either "line attributes" or line styles. I prefer "line attributes" as this matches withpenattributes and “style” is actually one of the attributes. - Following DOC: Add basic tutorial "Plotting polygons" #3593 (comment) by @seisman, using a more complicated line/curve like sine/cosine functions besides lines with two or more data points to make the tutorial more eye-catching.
Combined plot
import pygmt
size = 5
x = [-4, -3.5, -2, 1, 4]
y = [-3, 1, 2, 1, 4]
fig = pygmt.Figure()
fig.basemap(region=[-size, size] * 2, projection=f"X{size * 2}c", frame=1)
fig.plot(x=x, y=y, style="c0.25c", fill="gray30", label="data point")
fig.plot(x=x, y=y, pen="1p,brown", label="linear spline")
fig.plot(x=x, y=y, pen="1p,orange+s", label="Bezier cubic spline")
fig.plot(x=x, y=y, pen="1p,red", straight_line="x", label="stairs via x first")
fig.plot(x=x, y=y, pen="1p,purple", straight_line="y", label="stairs via y first")
fig.legend(position="jRB")
fig.show()Seperat plots
import pygmt
size = 5
x = [-4, -3.5, -2, 1, 4]
y = [-3, 1, 2, 1, 4]
fig = pygmt.Figure()
args_basemap = {"region": [-size, size, -size, size], "projection": f"X{size * 2}c", "frame": 1}
args_data = {"x": x, "y": y, "style": "c0.25c", "fill": "gray30", "label": "data point"}
fig.basemap(**args_basemap)
fig.plot(**args_data)
fig.plot(x=x, y=y, pen="1p,brown", label="linear spline")
fig.legend(position="jRB")
fig.shift_origin(xshift="w+1c")
fig.basemap(**args_basemap)
fig.plot(**args_data)
fig.plot(x=x, y=y, pen="1p,orange+s", label="Bezier cubic spline")
fig.legend(position="jRB")
fig.shift_origin(xshift="-w-1c", yshift="-h-1c")
fig.basemap(**args_basemap)
fig.plot(**args_data)
fig.plot(x=x, y=y, pen="1p,red", straight_line="x", label="stairs via x first")
fig.legend(position="jRB")
fig.shift_origin(xshift="w+1c")
fig.basemap(**args_basemap)
fig.plot(**args_data)
fig.plot(x=x, y=y, pen="1p,purple", straight_line="y", label="stairs via y first")
fig.legend(position="jRB")
fig.show()| Combined plot | Separat plots |
|---|---|
![]() |
![]() |
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation


Activity
yvonnefroehlich commentedon Jan 5, 2025
It's only indirectly related to this issue, but I just realized, that the +s modifier of
penis ignored for the outline of a polygon in casefillis used. Wondering / have to check if this is the expected behaviour.seisman commentedon Jan 6, 2025
Need to note this is just a "basic" tutorial, and it's better to focus on common situations only. More advanced line plottings can be in an "advanced" tutorial instead.
AisunZa commentedon Nov 8, 2026
Hi! I'd like to work on improving the "Plotting lines" tutorial.
I read the discussion about keeping the basic tutorial focused on common situations. My proposal is to add one concise example showing how
straight_line="x"andstraight_line="y"differ from the default direct connection between points.I'd keep the change limited to
examples/tutorials/basics/lines.py, without restructuring the rest of the tutorial.Would this be an appropriate scope for the basic tutorial, or would you prefer the example in an advanced tutorial?
Thanks!