add legend of a plot when names of each time series are saved in a vector
Show older comments
Hi,
I have the following Problem:
The matrix I would like to plot containes the Dates in the first column and the different time series in the following n columns, here an example:
A=[729393 1 0.8 0.2; 729396 0.9 0.7 0.25; 729397 1.02 0.95 0.18; 729398 1.2 1.1 0.1]
in order to plot the series and get the data on the x axis, I am using the following commands:
plot(A(:,1),A(:,2:end);
datetick('x','keepticks','keeplimits')
That works pretty good. One thing, I would like to add are the months so I can show year and months.
I tied to use datetick('x','mmmyyyy') but that does only Show me january of each year, I would like to see all months and alternative Jan, Apr, Jul, Oct
How can I do this?
The second thing I Need is a way to plot the legend using a vector where I saved the names of my series
let's say the vactor SeriesNames=[ 1 2 3] contains the names of my series. I tried to use legend(SeriesNames) but that does not work.
Is there anybody who can help?
regards
Accepted Answer
More Answers (0)
Categories
Find more on Legend in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!