MATLAB: Hourly 3d plot for rainfall with distinct line color for all 12 months

3d plotscolormapMATLAB

I am trying to plot rainfall hourly rainfall data for each hour of 365 days of the year as a 3d graph(Day of year, hour of day, Rainfall Intensity). I would like to color each month's data (12*30(say)) differently so as to make the plot more readable using a colorbar. Can someone guide me on this? The code i have written gives me single color lines for all of the values. Attaching the following image for reference.

Best Answer

MATLAB will treat each column of data as a different series. As a quick and dirty approach, you could reshape X,Y and Z so that the rows represent the hours of the day, and the columns represent the day of the year. Then, plotting using plot3 will automatically make each column (day) a separate line with a different color.
The default settings won't have enough colors for each day of the year. You can specify your own colors, and use the colororder function to define a unique color for each line.
opts = detectImportOptions("dummydata.xlsx",'Sheet',"Sheet2");opts = setvartype(opts,"y","duration");opts = setvaropts(opts,"y","DurationFormat","d");data = readtable("dummydata.xlsx",opts);data.y = hours(data.y);% Create 366 unique colors from the hsv colormapCO = jet(day(data.x(end),"dayofyear"));% Define a new colororder for the plot so each line has a different color.colororder(CO)plot3(reshape(data.x,24,[]),...    reshape(data.y,24,[]),reshape(data.z,24,[]))xlabel("Date")ylabel("Hour of day")●