2014-04-20 797 views
0

考虑到this question,我试图用两个独立的plot使用坐标轴而不是plotyy来解决问题,该坐标不能与'boxplot'和'plot ':绘制两个不同的图(y轴),在matlab中共享相同的x

%%% 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); 

但仍然没有得到我的最后阴谋正确的方式。有谁知道为什么?

+0

请张贴可执行代码。 (什么是box_panda_8?) – thewaywewalk

+0

@thewaywewalk,请看现在更新的问题;) – Amir

回答

1

在最后一行之前没有hold on

+0

我是多么愚蠢! tnx @丹尼尔,提到这一点!我仍然不知道为什么matlab的内置功能,即'plotyy'不起作用,因为我正在使用'plotyy(x,MPG,x,y2,'boxplot','plot')' – Amir

相关问题