From: Josh Jones on 27 Jul 2010 15:37 I am trying to plot a 3 x 1 subplot, with the same date range along the x axis, and I am having a couple of problems: - I can't get the x tick labels to show dates in the form MMDD. I have tried datetick(), but does not seem to work for some reason - I do not even want ticks or labels on the top two graphs. I tried set(gca, 'XTick', []), but it only works on the feather plot in the top most position and not the graph in the second position Both the middle and bottom plots use the plotyy command to plot on two y axes, and I am thinking the problem may be in there somewhere. Thanks for any help! -Josh
From: us on 27 Jul 2010 15:45 "Josh Jones" <joshua.jones(a)gi.alaska.edu> wrote in message <i2nchl$plo$1(a)fred.mathworks.com>... > I am trying to plot a 3 x 1 subplot, with the same date range along the x axis, and I am having a couple of problems: > > - I can't get the x tick labels to show dates in the form MMDD. I have tried datetick(), but does not seem to work for some reason > > - I do not even want ticks or labels on the top two graphs. I tried set(gca, 'XTick', []), but it only works on the feather plot in the top most position and not the graph in the second position > > Both the middle and bottom plots use the plotyy command to plot on two y axes, and I am thinking the problem may be in there somewhere. > > Thanks for any help! > > -Josh how - do you think - CSSMers can possibly help you without anything real, ie, a simple ML code/data example, to play with(?)... us
From: Rune Allnor on 27 Jul 2010 15:52 On 27 Jul, 21:37, "Josh Jones" <joshua.jo...(a)gi.alaska.edu> wrote: > I am trying to plot a 3 x 1 subplot, with the same date range along the x axis, and I am having a couple of problems: > > - I can't get the x tick labels to show dates in the form MMDD. I have tried datetick(), but does not seem to work for some reason > > - I do not even want ticks or labels on the top two graphs. I tried set(gca, 'XTick', []), but it only works on the feather plot in the top most position and not the graph in the second position > > Both the middle and bottom plots use the plotyy command to plot on two y axes, and I am thinking the problem may be in there somewhere. I think you are right that this has to do with PLOTYY. This script %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clf figure subplot(3,2,1) plotyy(1:10,randn(1,10),1:10,randn(1,10)) set(gca,'xtick',[]) subplot(3,2,3) plotyy(1:10,randn(1,10),1:10,randn(1,10)) set(gca,'xtick',[]) subplot(3,2,5) plotyy(1:10,randn(1,10),1:10,randn(1,10)) datetick('x',6) subplot(3,2,2) plot(1:10,randn(1,10)) set(gca,'xtick',[]) subplot(3,2,4) plot(1:10,randn(1,10)) set(gca,'xtick',[]) subplot(3,2,6) plot(1:10,randn(1,10)) datetick('x',6) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% shows the mess in the left column and the desired result in the right column (R2006a). Rune
From: Josh Jones on 27 Jul 2010 15:54 "Josh Jones" <joshua.jones(a)gi.alaska.edu> wrote in message <i2nchl$plo$1(a)fred.mathworks.com>... > I am trying to plot a 3 x 1 subplot, with the same date range along the x axis, and I am having a couple of problems: > > - I can't get the x tick labels to show dates in the form MMDD. I have tried datetick(), but does not seem to work for some reason > > - I do not even want ticks or labels on the top two graphs. I tried set(gca, 'XTick', []), but it only works on the feather plot in the top most position and not the graph in the second position > > Both the middle and bottom plots use the plotyy command to plot on two y axes, and I am thinking the problem may be in there somewhere. > > Thanks for any help! > > -Josh Oops, here is the code for the plot: [dir speed] = pol2cart( winddir, windsp); subplot (3, 1, 1); f = feather (dir, speed); for i = 1:length(f)-1 xData = get(f(i),'XData'); yData = get(f(i),'YData'); set(f(i),'XData',xData(1:2),'YData',yData(1:2)) end set (gca, 'xtick', []); subplot (3, 1, 2); [BX, Y3, Y4] = plotyy(date, precip, date, relhum); set(get(BX(1), 'Ylabel'), 'String', 'Precipitation per hour (mm)'); set(get(BX(2), 'Ylabel'), 'String', 'Relative Humidity (%)'); set(gca, 'XTick', []); subplot (3, 1, 3); [AX, Y1, Y2] = plotyy (date, temp, date, slp, 'plot' ); set(get(AX(1), 'Ylabel'), 'String', 'Temperature (C)'); set(get(AX(2), 'Ylabel'), 'String', 'Sea Level Pressure (mB)'); set(gca, 'xtickMode', 'manual', 'xTickLabel', day); I just added the last line, and it is putting the dates on top of the Matlab date numbers.
From: Steven_Lord on 27 Jul 2010 16:21 "Josh Jones" <joshua.jones(a)gi.alaska.edu> wrote in message news:i2ndhp$2kv$1(a)fred.mathworks.com... > "Josh Jones" <joshua.jones(a)gi.alaska.edu> wrote in message > <i2nchl$plo$1(a)fred.mathworks.com>... >> I am trying to plot a 3 x 1 subplot, with the same date range along the x >> axis, and I am having a couple of problems: >> >> - I can't get the x tick labels to show dates in the form MMDD. I have >> tried datetick(), but does not seem to work for some reason >> >> - I do not even want ticks or labels on the top two graphs. I tried >> set(gca, 'XTick', []), but it only works on the feather plot in the top >> most position and not the graph in the second position >> >> Both the middle and bottom plots use the plotyy command to plot on two y >> axes, and I am thinking the problem may be in there somewhere. >> >> Thanks for any help! >> >> -Josh > > Oops, here is the code for the plot: > > [dir speed] = pol2cart( winddir, windsp); > subplot (3, 1, 1); > f = feather (dir, speed); > for i = 1:length(f)-1 > xData = get(f(i),'XData'); > yData = get(f(i),'YData'); > set(f(i),'XData',xData(1:2),'YData',yData(1:2)) > end > set (gca, 'xtick', []); > > subplot (3, 1, 2); > [BX, Y3, Y4] = plotyy(date, precip, date, relhum); > set(get(BX(1), 'Ylabel'), 'String', 'Precipitation per hour (mm)'); > set(get(BX(2), 'Ylabel'), 'String', 'Relative Humidity (%)'); > set(gca, 'XTick', []); Try replacing that line with: set(BX(1), 'XTick', []); datetick(BX(2), 'mmdd') % I assume you want month followed by day, right? If that doesn't work, rerun your original code and try this again but interchange BX(1) and BX(2) in those commands. > subplot (3, 1, 3); > [AX, Y1, Y2] = plotyy (date, temp, date, slp, 'plot' ); > set(get(AX(1), 'Ylabel'), 'String', 'Temperature (C)'); > set(get(AX(2), 'Ylabel'), 'String', 'Sea Level Pressure (mB)'); > set(gca, 'xtickMode', 'manual', 'xTickLabel', day); > > I just added the last line, and it is putting the dates on top of the > Matlab date numbers. Right. You're only changing the properties of _one_ of the two axes whose handles PLOTYY returns -- you need to adjust _both_. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
Pages: 1 Prev: A/D Quantization error- reconciling Next: error while executing datenum |