Dear friends,
I would like to draw scatter diagram with 3-y axis. Please help me.
Thank you so much!

 採用された回答

Etsuo Maeda
Etsuo Maeda 2019 年 8 月 28 日

1 投票

5 件のコメント

Tien Nguyen
Tien Nguyen 2019 年 8 月 28 日
Hi,
I found this link before, and it is for plot not for scatter.
I also tried did for scatter, but I could not get the diagram because the codes in that link for 'plot' only.
Etsuo Maeda
Etsuo Maeda 2019 年 8 月 29 日
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
Tien Nguyen 2019 年 9 月 2 日
That is great! Thank you so much for your help!
Etsuo Maeda
Etsuo Maeda 2019 年 9 月 2 日
:-)
Ahmad Bayhaqi
Ahmad Bayhaqi 2022 年 4 月 9 日
Hi, thank you very much for this code. This also works for me. Then, is there a way to put legend and ylabel in this code? @Etsuo Maeda

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by