How to plot a one year rainfall data

I have a 31X12 rainfall data and i want it to plotted in 2D from January 1 to December 31. X- axis will be January 1 to December 31 2010 and Y will be the data from the 31x12 matrix. Thank you

3 Comments

How are your date stamps stored? Are they in a [1x12] or [31x1] vector? Are they in datetime() format? Is your data a timetable?
More detail would be helpful. Even better, a sample of your data.
Here is the data.
Adam Danz
Adam Danz on 29 Apr 2019
Edited: Adam Danz on 29 Apr 2019
Have you read the data into matlab yet? There are multiple ways to do that and if an answer is provided that doesn't match the format of your data in matlab, it won't be as useful to you.

Sign in to comment.

 Accepted Answer

Adam Danz
Adam Danz on 29 Apr 2019
Edited: Adam Danz on 29 Apr 2019
I read in the data using readtable() but you can use any method as long as your data are organized into an [m x n] array with m days and n months (NaNs are used at the end of short months).
A = readtable('2010.csv', 'ReadRowNames', 1);
A.Var13 = []; %get rid of extra column
figure
ph = plot(table2array(A), 'LineWidth', 2);
axis tight
xlabel('day of month')
ylabel('rain fall')
legend(ph, A.Properties.VariableNames)
You can use a different color scheme with 12 unique colors, of course.
190429 185356-Figure 1.jpg

3 Comments

Is there a way to plot this using one line and x-axis has 365 days. Thank you so much.
Yes, there's a way. Why do I have the feeling you didn't try to figure out a way to do it?
data = table2array(A);
x = datetime('Jan/01/2010') : 1 : datetime('Dec/31/2010');
data(isnan(data)) = []; %now it's a vector without the NaN fillers.
figure
190429 191956-Figure 3.jpg
"I've searched for the answer but can't find the right answer. Thank you so much. BTW, I'm absolutely beginner and I started using matlab just last week."
Make sure you go through each line of my code and understand what I'm doing. Most of it is at a beginner's level so it will be a good learning opportunity.

Sign in to comment.

More Answers (1)

STS-95
STS-95 on 29 Apr 2019
I've searched for the answer but can't find the right answer. Thank you so much. BTW, I'm absolutely beginner and I started using matlab just last week.

Categories

Find more on Weather and Atmospheric Science in Help Center and File Exchange

Tags

Asked:

on 29 Apr 2019

Commented:

on 29 Apr 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!