pygmt.Figure.vlines
- Figure.vlines(x, ymin=None, ymax=None, pen=None, label=None, no_clip=False, perspective=None)
Plot one or multiple vertical line(s).
This method is a high-level wrapper around
pygmt.Figure.plot
that focuses on plotting vertical lines at X-coordinates specified by thex
parameter. Thex
parameter can be a single value (for a single vertical line) or a sequence of values (for multiple vertical lines).By default, the Y-coordinates of the start and end points of the lines are set to be the Y-limits of the current plot, but this can be overridden by specifying the
ymin
andymax
parameters.ymin
andymax
can be either a single value or a sequence of values. If a single value is provided, it is applied to all lines. If a sequence is provided, the length ofymin
andymax
must match the length ofx
.The term “vertical” lines can be interpreted differently in different coordinate systems:
Cartesian coordinate system: lines are plotted as straight lines.
Polar projection: lines are plotted as straight lines along radius.
Geographic projection: lines are plotted as meridians along constant longitude.
- Parameters:
x (
float
|Sequence
[float
]) – X-coordinates to plot the lines. It can be a single value (for a single line) or a sequence of values (for multiple lines).ymin/ymax – Y-coordinates of the start/end point(s) of the line(s). If
None
, defaults to the Y-limits of the current plot.ymin
andymax
can either be a single value or a sequence of values. If a single value is provided, it is applied to all lines. If a sequence is provided, the length ofymin
andymax
must match the length ofx
.pen (
str
|None
, default:None
) – Pen attributes for the line(s), in the format of width,color,style.label (
str
|None
, default:None
) – Label for the line(s), to be displayed in the legend.no_clip (
bool
, default:False
) – IfTrue
, do not clip lines outside the plot region. Only makes sense in the Cartesian coordinate system.perspective (
str
|bool
|None
, default:None
) – Select perspective view and set the azimuth and elevation angle of the viewpoint. Refer topygmt.Figure.plot
for details.
Examples
>>> import pygmt >>> fig = pygmt.Figure() >>> fig.basemap(region=[0, 10, 0, 10], projection="X10c/10c", frame=True) >>> fig.vlines(x=1, pen="1p,black", label="Line at x=1") >>> fig.vlines(x=2, ymin=2, ymax=8, pen="1p,red,-", label="Line at x=2") >>> fig.vlines(x=[3, 4], ymin=3, ymax=7, pen="1p,black,.", label="Lines at x=3,4") >>> fig.vlines(x=[5, 6], ymin=4, ymax=9, pen="1p,red", label="Lines at x=5,6") >>> fig.vlines( ... x=[7, 8], ymin=[0, 1], ymax=[7, 8], pen="1p,blue", label="Lines at x=7,8" ... ) >>> fig.legend() >>> fig.show()