[英]Plotting two different plots(y axes), sharing the same x in matlab
考慮到這個問題 ,我試圖用兩個單獨的圖來解決這個問題,而不是使用axis而不是plotyy,這在'boxplot'和'plot'中效果不佳:
%%% definition of my x=y line axes
y2 = 1:6;
x2 = 1:6;
% Plot the first data set using boxplot, that results in 6 boxes
load carsmall;
boxplot(MPG,Origin)
% Get the axes and configure it
ax1 = gca;
set(ax1,'XColor','r','YColor','r')
%Create the new axes
ax2 = axes('Position',get(ax1,'Position'),...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none',...
'XColor','k','YColor','k');
% Plot the second data set with the new axes
hl2 =plot(x2,y2,'Color','k','parent',ax2);
但我仍然沒有以正確的方式得出我的最終情節。 有人知道為什么嗎?
在最后一行之前有一個丟失的hold on
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.