# Alternate y-axis in Plotting

**URL:** <https://discourse.julialang.org/t/alternate-y-axis-in-plotting/92152>\
**Category:** General Usage\
**Created:** [December 26, 2022, 5:19pm UTC](https://discourse.julialang.org/t/alternate-y-axis-in-plotting/92152 "2022-12-26T17:19:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)\
**Post date:** [December 26, 2022, 5:19pm UTC](https://discourse.julialang.org/t/alternate-y-axis-in-plotting/92152/1 "2022-12-26T17:19:02Z")

</div>

I am using Plots to build a plot line by line. My initial intent was to plot one line using the left y-axis and then the next line using the right y-axis. For the first time through, using twinx() works well. However then I cannot seem to figure out how to plot the third line on the left y-axis. Using help on twinx() seems to indicate that this is not possible. Is there another command that will allow me to control whether to plot a line on the left or right y-axis?

One try is given below.

```julia
julia> x_arr = sort(rand(10));

julia> y1_arr = x_arr;

julia> y2_arr = 1.1 .* x_arr;

julia> y3_arr = 1.2 .* x_arr;

julia> y4_arr = 1.3 .* x_arr;

julia> ep1 = plot(title="A Plot", legend=:topright)

julia> sep1 = twinx(ep1);

julia> ep1 = plot!(ep1, x_arr, y1_arr)

julia> sep1 = plot!(sep1, x_arr, y2_arr)

julia> ep1 = plot!(ep1, x_arr, y3_arr)

julia> sep1 = plot!(sep1, x_arr, y4_arr)

julia>

```
