Help with labelling the axes of a plot.
1 view (last 30 days)
Show older comments
I have a simple plot of data measured once a month over 4 years. My code looks like this:
t=1:1:48
ydata=[48 different values]
plot(t,ydata)
I'm still very much a novice with MATLAB, & while I know to add a label to the x-axis, what I would like to do with this plot on the x-axis, is split it into sections of 12 numbers to clearly show the results of each year on the plot. So that there would be one seperate section for t=1:12, and another for t=13:24, etc. Any help with this would be much appreciated, thank you very much.
2 Comments
Walter Roberson
on 18 Mar 2019
Do you want to create two separate plots? If not then how would you like to mark the two different sections?
Accepted Answer
dpb
on 18 Mar 2019
Edited: dpb
on 18 Mar 2019
Something like
hL=plot(reshape(t,12,[]),reshape(y,12,[]));
is really easy to get the effect by ML's treating each column on an array as a separate variable. The one thing might not care for w/o some fixup is this leaves a break between the line segments...so, another way would be
plot(t,y,'k-') % draw solid line first
hold on
hL=plot(reshape(t,12,[]),reshape(y,12,[]),'*-'); % then add colored markers
Add legends to label color, change symbols, etc., to "salt to suit!"...
More Answers (0)
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!