Following this example:
I understand how to plot with multiple axes. But when I add the fill function to display a confidence interval to each line the second fill function messes up the axes properties. My code is:
figurex1 = 0:0.1:40;y1 = 4.*cos(x1)./(x1+2);fill([x1 fliplr(x1)],[y1+0.1 fliplr(y1-0.1)],'b')alpha(0.2) line(x1,y1,'Color','k') ax1 = gca; % current axes
ax1.XColor = 'r';ax1.YColor = 'r'; ax1_pos = ax1.Position; % position of first axes
ax2 = axes('Position',ax1_pos,... 'XAxisLocation','top',... 'YAxisLocation','right',... 'Color','none'); x2 = 1:0.2:20;y2 = x2.^2./x2.^3; fill([x2 fliplr(x2)],[y2+0.1 fliplr(y2-0.1)],'r','Parent',ax2)alpha(0.2)line(x2,y2,'Parent',ax2,'Color','k')
If I comment out the second fill function it works nicely upon getting annoying tickmarks on ax2 from ax1. Where is my problem? Thanks in advance!
/Markus
Best Answer