Problem with axes in 4 axis plot

Im currently trying to plot 4 variables (one on each axis) that sum to 100. However in plotting the second set of axes at the top and right, the scatter plot seems to go astray.
if true
scatter(x1,y1,1,C)
ax1=gca;
ax1_pos = ax1.Position; % position of first axes
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none');
ax2=gca;
scatter(x2,y2,1,C)
end
Thank you in advance

回答 (1 件)

Adam
Adam 2015 年 3 月 2 日

0 投票

You should pass the axes to the scatter function explcitly rather than just having it plot on the current axes. e.g
scatter( ax1, x1, y1, 1, C );
after creating ax1.
Creating ax2 and then overwriting the ax2 variable with gca is also not a good idea. At best it is redundant since the aim is to assign to ax2 the value that it already contains.

3 件のコメント

Hillaryfor2016
Hillaryfor2016 2015 年 3 月 2 日
Hey Adam, Thanks for the speedy reply. I tried something like this before and still couldn't get it to work. I though that using gca might change the axes handle.
if true
% code
end
ax1=gca;
ax1_pos = ax1.Position; % position of first axes
scatter(ax1,x1,y1,1,C)
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none');
scatter(ax2,x2,y2,1,C)
Adam
Adam 2015 年 3 月 2 日
And what is the result? What aspect of it doesn't work?
Hillaryfor2016
Hillaryfor2016 2015 年 3 月 2 日
編集済み: Hillaryfor2016 2015 年 3 月 2 日
Its plotting both axes to the same x and y. I specified it like that originally then started using the gca.

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

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

タグ

質問済み:

2015 年 3 月 2 日

編集済み:

2015 年 3 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by