考虑到this question,我试图用两个单独的图来解决这个问题,而不是使用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);
但我仍然没有以正确的方式得到我的最终情节。有谁知道为什么?
答案 0 :(得分:1)
在最后一行之前缺少hold on
。