Is there a Plots.jl equivalent of axvspan? I'd like to highlight a region of my plot. vline! looked promising at first, but its width parameter is in pixel, whereas I would like it in x-coordinates (as in matplotlib)
As of now, I'm afraid that, to replicate the python example, you'd have to do:
plt = plot(0:9)
x1, x2 = 3, 6
y1, y2 = ylims(plt)
plot!(plt, [x1, x2, x2, x1], [y1, y1, y2, y2], color="red", alpha=0.5, seriestype = :shape)
Maybe it'd be nice to have a rectangle as well as a vspan and hspan seriestype, which could be implemented using shape.
Thank you, that works! I used linealpha=0 to take out the hard edges.
Glad it worked for you. Better to keep the issue open though as it's a good candidate for a series recipe potentially called vspan (and hspan). The recipe could probably already have the transparency default to 0.5 so that the new syntax would be:
plt = plot(0:9)
plot!([3, 6], color="red", seriestype = :vspan)
Better to keep the issue
Agreed; your solution is perfect for what I need, but the fact that the rectangles are not infinite in the y-axis shows up when panning/zooming-out.
You can now use vspan and hspan. See #1445
Most helpful comment
As of now, I'm afraid that, to replicate the python example, you'd have to do:
Maybe it'd be nice to have a
rectangleas well as avspanandhspanseriestype, which could be implemented usingshape.