簡體   English   中英

繪制兩個不同的圖(y軸),在matlab中共享相同的x

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM