Quinten
Quinten

Reputation: 41225

Change origin of plot in Julia

Imagine the following simple plot with Plots

using Plots
plot([1,2,3,4,5], [1,2,3,4,5])

Output:

enter image description here

How can we change the origin to 0 in the plot above?

Upvotes: 3

Views: 379

Answers (1)

Quinten
Quinten

Reputation: 41225

It is actually very simple, you can use the arguments xlims and ylims and pass 0 and Inf as the limits to force the axis to an origin of 0. Here is a reproducible example:

using Plots
plot([1,2,3,4,5], [1,2,3,4,5], xlims = [0,Inf], ylims = [0,Inf])

Output:

enter image description here

As you can see the origin has been changed!

Upvotes: 3

Related Questions