# Change ylabel after twinx is generated?

**URL:** <https://discourse.julialang.org/t/change-ylabel-after-twinx-is-generated/110969>\
**Category:** Visualization\
**Tags:** plotting, plots\
**Created:** [February 29, 2024, 6:16pm UTC](https://discourse.julialang.org/t/change-ylabel-after-twinx-is-generated/110969 "2024-02-29T18:16:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iddingsite](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iddingsite/32/31840_2.png) [@Iddingsite](https://discourse.julialang.org/u/Iddingsite)\
**Post date:** [February 29, 2024, 6:16pm UTC](https://discourse.julialang.org/t/change-ylabel-after-twinx-is-generated/110969/1 "2024-02-29T18:16:56Z")

</div>

Hey everyone,

I would like to know if it is possible to change only one label name of a simple plot containing a twin axis using Plots. Of course I know that you can do that when calling twinx, but for one of my use, I need to do it AFTER creating the plot.

This is the MWE:

```julia
p = plot()
p_twin = twinx(p)

plot!(p, ylabel="sin(x)")

```

which output this:

 ![Capture d’écran 2024-02-29 à 19.15.15](https://global.discourse-cdn.com/julialang/original/3X/a/8/a80461c6c9df38ee6edc2d820610d9b30805e197.png)

As I am only replacing `p`, I would expect to only change the label of `p` but that doesn’t seem to be the case…

I would like to be able to only modify the y label on the left.

---

<div class="post-metadata">

**Author:** ![Iddingsite](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iddingsite/32/31840_2.png) [@Iddingsite](https://discourse.julialang.org/u/Iddingsite)\
**Post date:** [February 29, 2024, 6:20pm UTC](https://discourse.julialang.org/t/change-ylabel-after-twinx-is-generated/110969/2 "2024-02-29T18:20:09Z")

</div>

Okay, I figured it out… I will leave it here in case someone needs it!

```julia
p = plot()
p_twin = twinx(p)

plot!(p[1], ylabel="sin(x)")

```

which gives:

 ![Capture d’écran 2024-02-29 à 19.19.49](https://global.discourse-cdn.com/julialang/original/3X/d/5/d558c3b0b9850a2a719db1cdc4a2b914e6b21283.png)

I didn’t understand that twinx was effectively creating another subplot…
