UltraScienceGuy
UltraScienceGuy

Reputation: 65

Plot Vertical/Horizontal Lines on Multiple Julia Graphs

I was trying to make several Julia graphs with different arrangements of horizontal/vertical lines:

using Plots


plot_array = Any[]
v_array = [1, 3]
h_array = [9, 10]

push!(variogram_array, plot([1, 2, 3, 4, 5], [1, 4, 9, 16, 25]))
push!(variogram_array, plot([1, 2, 3, 4, 5], [1, 16, 10, 15, 23]))

for i in 1:length(plot_array)
    display(plot(variogram_array..., size = (1000,1000)))
    plot!([v_array[i]], seriestype="vline",label= "rand",line=(:dot, 7))
    plot!([h_array[i]], seriestype="hline",label= "rand",line=(:dot, 7))
end

This code outputs the main graphs, but doesn't include the horizontal and vertical lines as I need it to.

Is there any way to remedy this? Should I be using Plotly instead?

Upvotes: 2

Views: 822

Answers (1)

Bill
Bill

Reputation: 6086

Changing the plot! function to vline! and hline! and displaying after the lines are added shows the two plots with lines:

for i in 1:length(variogram_array)
    plt = plot(variogram_array..., size = (1000,1000))
    vline!([v_array[i]], label= "rand",line=(:dot, 7))
    hline!([h_array[i]], label= "rand",line=(:dot, 7))
    display(plt)
end

Upvotes: 1

Related Questions