Open briochemc opened 4 years ago
As a hack, it is possible to get a vertical plot as follows.
Here's a simple x-y plot with a vertical ribbon specified with min and max values for each y value in ribbon
:
using Plots
seq = 0:30.0
values = rand(length(seq)) .- 0.5
ribbon = (seq ./ 5, seq ./ 4)
plot_horiz = plot(seq, values, ribbon = ribbon, fillcolor=:lightblue)
A horizontal version (swapping x and y axes) can be made like this (at least with the default GR backend in Julia 1.8.2... haven't tested any other backends):
plot_vert = plot(values, seq)
function make_hribbon_shape(ys, values, ribbon)
# make the ribbon as a shape to fill in
rib_min = values .- ribbon[1] # the lower edge of the ribbon
rib_max = values .+ ribbon[2] # the upper edge of the ribbon
ys = [ys; [ys[end]; ys[end]]; reverse(ys); [ys[1]; ys[1]]]
xs = [rib_max; [rib_max[end],rib_min[end]]; reverse(rib_min); [rib_min[1]; rib_max[1]]]
return xs, ys
end
ribbon_xs, ribbon_ys = make_hribbon_shape(seq, values, ribbon)
plot_vert=plot!(plot_vert,
ribbon_xs, ribbon_ys,
fill=true, linewidth=0, fillalpha = 0.5, fillcolor=:lightblue,
label=nothing)
I've been using this method for a bit, and I think I originally got it from here
While vertical ribbons works very nicely like in
it would be great to be able to do the same when axes are swapped, maybe with a
xribbon
like we already havexerror
like so:For comparison, it works with
xerror
:produces