# Is there a simple way to swap the x and y axes in `Plots.jl` after a figure is plotted?

Note this is not `flip`, which flips the x and y axes by themselves. I want to exchange the y and x axes, like a transposition of the figure.

To transpose the plot after the figure has been plotted, you could do:

``````using Plots

x = range(0,2π,100)
y = sin.(x)
plot(x,y)

p = Plots.current()
y1 = p.series_list[:x]
x1 = p.series_list[:y]
plot(x1, y1)
``````
1 Like

Thank you. Also, according to @SimonChrist on Slack, `permute=(:x, :y)` also works.

``````using Plots

x = range(0, 2π, 100)
y = sin.(x)
plot(x, y; permute=(:x, :y))
``````
1 Like

That doesn’t seem to work after a figure is plotted (as per OP’s title).
Also, in that case it is simpler to write: `plot(y, x)` for the same result.

You are right. Thanks!

Actually, what I want is something that I can put into my custom recipes. So

``````@recipe function f(args...)
...
permute-->(:x, :y)
...
end
``````

is what I finally want. There is some confusion in the question. Sorry!