logankilpatrick
logankilpatrick

Reputation: 14561

How to scale a plot in Julia using Plots.jl

I am currently trying to zoom in on a plot which is very small. How can I restrict the x-axis and y-axis such that I can see my plot up close?

Here is my current code, which works, but my plot is small compared to the rest of the image(which is actually correct, I just want to especially zoom in).

img = load("/Users/xxxx/xxxx/xxxx-xxx.png")

plot!(img)
plot!(x_coordinate_holder, y_coordinate_holder, color = :black,linewidth=0.4)

How can I only show specific ranges of x and y coordinates?

Upvotes: 2

Views: 12073

Answers (1)

logankilpatrick
logankilpatrick

Reputation: 14561

Here is how I scaled it variably. In my case, I am plotting a traverse of an agent on a map, so I want the scale to dynamically change(hence the use of min and max).

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

print("X-Coords: ", xMin, ", ", xMax, " Y-Coords: ", yMin, ", ", yMax, "\n")

plot(img, xlim=(xMin,xMax), ylim=(yMin, yMax), yflip = false)
plot!(x_coordinate_holder, y_coordinate_holder, color = :black, linewidth=0.4)

Upvotes: 2

Related Questions