# Can I change axis position in Plots

**URL:** https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966
**Category:** New to Julia
**Created:** [May 7, 2020, 3:55pm UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966 "2020-05-07T15:55:19Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Eris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eris/32/8438_2.png) [@Eris](https://discourse.julialang.org/u/Eris)
#### Post date: [May 7, 2020, 3:55pm UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/1 "2020-05-07T15:55:19Z")

</div>

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/](https://docs.juliaplots.org/latest/generated/attributes_axis/)

---

<div class="post-metadata">

### Author: ![L\_Adam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/l_adam/32/12086_2.png) [@L\_Adam](https://discourse.julialang.org/u/L_Adam)
#### Post date: [May 7, 2020, 4:20pm UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/2 "2020-05-07T16:20:01Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Eris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eris/32/8438_2.png) [@Eris](https://discourse.julialang.org/u/Eris)
#### Post date: [May 7, 2020, 4:29pm UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/3 "2020-05-07T16:29:45Z")

</div>

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

---

<div class="post-metadata">

### Author: ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)
#### Post date: [May 7, 2020, 5:50pm UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/4 "2020-05-07T17:50:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [May 7, 2020, 6:02pm UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/5 "2020-05-07T18:02:53Z")

</div>

> [@L\_Adam](#):
>
> plot(f, 0, 5, xlabel = “x”, ylabel = “y”, framestyle = :zerolines)

What about this:

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

```

![test](https://global.discourse-cdn.com/julialang/original/3X/7/b/7b8686bbf298c0bf7ff862ea761de87a16e75c7d.png)

---

<div class="post-metadata">

### Author: ![Eris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eris/32/8438_2.png) [@Eris](https://discourse.julialang.org/u/Eris)
#### Post date: [May 7, 2020, 6:13pm UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/6 "2020-05-07T18:13:28Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [May 7, 2020, 6:15pm UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/7 "2020-05-07T18:15:45Z")

</div>

> 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?

---

<div class="post-metadata">

### Author: ![Eris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eris/32/8438_2.png) [@Eris](https://discourse.julialang.org/u/Eris)
#### Post date: [May 7, 2020, 6:25pm UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/8 "2020-05-07T18:25:23Z")

</div>

I used AxisOrigin in Mathemtica to position the x-axis at y=3 and this is the output  
 ![Screenshot from 2020-05-07 20-23-25](https://global.discourse-cdn.com/julialang/original/3X/e/5/e56cd703a6ca16e457d0e80f660f15da57ef37e4.png)

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [May 7, 2020, 6:35pm UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/9 "2020-05-07T18:35:03Z")

</div>

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

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

```

![test](https://global.discourse-cdn.com/julialang/original/3X/0/2/02cdd6fdc4783666448922c151b02491ff866e4e.png)

---

<div class="post-metadata">

### Author: ![Eris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eris/32/8438_2.png) [@Eris](https://discourse.julialang.org/u/Eris)
#### Post date: [May 7, 2020, 6:37pm UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/10 "2020-05-07T18:37:19Z")

</div>

I like it 😄 Thank you!

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [May 7, 2020, 8:16pm UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/11 "2020-05-07T20:16:53Z")

</div>

I find that a pretty confusing graph…

---

<div class="post-metadata">

### Author: ![mcmuffin6o](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@mcmuffin6o](https://discourse.julialang.org/u/mcmuffin6o)
#### Post date: [December 1, 2023, 5:27am UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/12 "2023-12-01T05:27:22Z")

</div>

Would It be possible to do something like this on a 3D plot? GR has decided I don’t need to see the axes if I want to rotate the plot:

Edit: This reply essentially became a duplicate of [this other reply](https://discourse.julialang.org/t/3d-plots-change-axis-intersection-inverse-axis/51109/11). See visuals and workaround there.

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [December 1, 2023, 6:59am UTC](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/13 "2023-12-01T06:59:10Z")

</div>

[Check workaround here](https://discourse.julialang.org/t/how-can-i-move-an-axis-in-a-3d-plot-so-that-it-is-shown-outside-of-the-grid/96365).
