# Can I change axis position in Plots

I’m trying to change an axis position. For example make the xaxis at y=0 instead of y=-3 here

using Plots
f(x)=x-3
plot(f,0,5,xlabel=“x”,ylabel= “y”)

I tried the documentation for Plots but I didn’t find a possible option in axis attributes
https://docs.juliaplots.org/latest/generated/attributes_axis/

maybe you want `plot(f, 0, 5, xlabel = "x", ylabel = "y", framestyle = :zerolines)`?

1 Like

This is good but what I really want is to control the position of the axis not nesccarilly keep it at y=0.

There is no way to do this rather than modifying the backend plot object after the fact or use the `etra_kwargs` mechanism, thats currently only implemented for the `pgfplotsx` backend

1 Like

``````f(x)=x-3
plot(f, 0, 5, xlabel = "x", ylabel = "y", ylims=(0,Inf), xlims=(3,Inf), legend=:topleft)
``````

But that didn’t shift the x-axis, it is still at y=0

For example make the xaxis at y=0

Hmmm, I suppose I don’t understand what the goal is then. Can you post an example of an output you’re trying to achieve?

I used AxisOrigin in Mathemtica to position the x-axis at y=3 and this is the output

I see. A quick (and dirty) way would be to just cheat by manually specifying the tick labels, like this:

``````plot(
f, 0, 5,
legend=false,
framestyle=:origin,
yticks=(-3:3, ["\$i" for i in 0:6])
)
``````

4 Likes

I like it Thank you!

1 Like

I find that a pretty confusing graph…

4 Likes