# Scatter 3y-axis

7 views (last 30 days)
Tien Nguyen on 22 Aug 2019
Commented: Etsuo Maeda on 2 Sep 2019
Dear friends,
Thank you so much!

Etsuo Maeda on 28 Aug 2019

Show 1 older comment
Etsuo Maeda on 29 Aug 2019
OK, just try to rewrite the logic with Axes properties. It works fine in R2019a.
clear; close all;
% create dummy data
x = 1:10;
y1 = rand(1, 10);
y2 = rand(1, 10)*10;
y3 = rand(1, 10)*100;
% create Figure f
f = figure;
% create Axes ax1
ax1 = axes('Parent', f);
ax1.NextPlot = 'replacechildren';
% create invisible Axes ax2
ax2 = axes('Parent', f);
ax2.NextPlot = 'replacechildren';
ax2.Color = 'none';
ax2.XAxis.Visible = 'off';
ax2.YAxis.Visible = 'off';
% create invisible Axes ax3
ax3 = axes('Parent', f);
ax3.NextPlot = 'replacechildren';
ax3.Color = 'none';
ax3.XAxis.Visible = 'off';
ax3.YAxis.Visible = 'off';
% plot scatter data x, y1, y2, y3
scatter(ax1, x, y1, 'ro')
scatter(ax2, x, y2, 'gx')
scatter(ax3, x, y3, 'b*')
% create dummy Axes, dAx1
dAx1 = ax1;
dAx1.YColor = 'r';
% create dummy Axes, dAx2 with right YAxis
dAx2 = axes('Parent', f);
dAx2.YColor = 'g';
dAx2.Color = 'none';
dAx2.XAxis.Visible = 'off';
dAx2.YAxisLocation = 'right';
dAx2.YLim = ax2.YLim;
% create dummy Axes, dAx3 with offset YAxis
dAx3 = axes('Parent', f);
dAx3.YColor = 'b';
dAx3.Color = 'none';
dAx3.XAxis.Visible = 'off';
Pos = ax1.Position;
dAx3.Position = Pos + [-0.06 0 0 0];
dAx3.YLim = ax3.YLim;
Tien Nguyen on 2 Sep 2019
That is great! Thank you so much for your help!
Etsuo Maeda on 2 Sep 2019
:-)