logankilpatrick
logankilpatrick

Reputation: 14561

How to get a plot in Julia using Plots.jl to show?

I have the following code that used to work to plot some basic stuff onto an image. Now it is not working... I cannot see why, and I am hoping someone else can :)

Here is the code:

n = 1
for item in 1:length(x_coordinate_holder)
    x_coordinate_holder[n] = x_coordinate_holder[n] / 20
    n = n + 1
end
#print(x_coordinate_holder)

c = 1
for items in 1:length(y_coordinate_holder)
    y_coordinate_holder[c] = y_coordinate_holder[c] / 20
    c = c + 1
end
#print(y_coordinate_holder)


img = load("path_to_image") 

xMin = minimum(x_coordinate_holder)-30
xMax = maximum(x_coordinate_holder)+30
yMin = minimum(y_coordinate_holder)-30
yMax = maximum(y_coordinate_holder)+30

#print("X-Coords: ", xMin, ", ", xMax, " Y-Coords: ", yMin, ", ", yMax, "\n")
gr()
plot1 = plot(img, xlim=(xMin,xMax), ylim=(yMin, yMax), yflip = false)
plot1 = plot!(x_coordinate_holder, y_coordinate_holder, color = :black, linewidth=0.4)
plot2 = plot(e_holder, color = :orange, linewidth=2)
plot(plot1, plot2)
gui()

In this code, x_coordinate_holder, y_coordinate_holder, e_holder are just arrays with doubles in them; Nothing fancy. The code runs, it just doesn't plot anything. I also have "using Plots" at the top of the file and did a test plot with gr() in a different file and it worked fine.

Thanks!

Upvotes: 2

Views: 1357

Answers (1)

logankilpatrick
logankilpatrick

Reputation: 14561

Doing display(plot) will get it to show!

Upvotes: 2

Related Questions