This code:
figure(1)
clf
x=-10:0.1:10;
subplot(2,1,1)
plot(x,sin(x))
xlabel('x','fontsize',12)
ylabel('Sin(x)','fontsize',12)
text(-13,1,'(1)','fontsize',12)
subplot(2,1,2)
plot(x,2 * sin(x))
xlabel('x','fontsize',12)
ylabel('2 * Sin(x)','fontsize',12)
text(-13,1,'(2)','fontsize',12)
produces this graph:
Notice the text at (-13,1)? It is positioned based upon the coordinate system used for the plot. Unless you adjust for this you're going to get bad results like I've shown here. Fontsize isn't affected so getting the position correct can be complicated if one doesn't use some tricks. I'll be doing some tests this afternoon to see if I can turn hold on and build the plot using one axis setting and position the text using another. I'll let you know what I find.
The second issue is the xlabel on the second subplot. For some reason it gets chopped off. There may be quite a few details one will need to remember to produce nice plots. One might want to build a library of sample plots so the code to produce them is kept handy.
No comments:
Post a Comment