Hello,

I would like to add 1. a single vertical line and 2. a series of vertical lines to a PyPlot chart. I have, let’s say, an x value of 38, how do I plot a vertical line on that point?

And if I create a vector with multiples of that value so that X = [0, 1, 2, 3]*38, can I plot that in a single line?

Thank you

My method is to plot them all in one go. Each vertical line consists of three `x`

values and three `y`

values. The first two `x`

values are the same, the position of the vertical line. The third one doesn’t matter, I usually use a NaN. The first `y`

value is the minimum of the plot or the minimum `y`

limit. The second `y`

value is the maximum of the plot or the maximum of the `y`

limit. The third value is a NaN. This prevents each vertical line from being connected.

Take a look at the vlines function which does exactly what you are looking for.

P.s: `axvlines`

is also relevant if you want the line to automatically cover the whole y-range. In general whenever you have a question about how to do something in `PyPlot`

I would recommend first trying to look up in your favorite search engine `"matplotlib DO SOMETHING"`

, as there is a good chance that someone already answered this question in the python community (and the syntax from within Julia is almost identical) . For example in this case `"matplotlib add vertical line"`

will lead you to the answer.