# Add second y axis for a single data

2 views (last 30 days)
Gunay Gazaloglu on 27 Oct 2022
Commented: Gunay Gazaloglu on 27 Oct 2022
I have a problem adding a second y-axis; all solutions point out that I need another data set to have a second y-axis. However, I want to have two y-axis for a single point while the x-axis is the same.
For instance;
point=(3,6), and I want to show that on the right y-axis side, the point (3,6) has a 0.5 value, so the general notation could be as (x,y1,y2)=(3,6,0.5)
first data
For example;
x=[3,5,6,8,11]
y1=[6,7,9,14,17]
I want right y axis to be
y2=[0.5,2,5,7,11]
.
Torsten on 27 Oct 2022
I think what you need is plot3, not a second y-axis.

Alberto Cuadra Lara on 27 Oct 2022
Hello Gunay,
Use yyaxis, here is a simple example.
Best,
Alberto
x = [3,5,6,8,11];
y1 = [6,7,9,14,17];
y2 = [0.5,2,5,7,11];
hold on; axis tight
plot(x, y1);
yyaxis right;
plot(x, y2);
Gunay Gazaloglu on 27 Oct 2022
Thank you so much!

### Categories

Find more on Axis Labels in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by