# Plot in a script with three time series, each series has to be a different color

4 views (last 30 days)
Aasiya Syed on 19 Apr 2020
Answered: Vimal Rathod on 23 Apr 2020
I made a plot with three different time series, each series has to be plotted with lines and each series has a different color.
% temperature time series
% loading three different temperature gauges in
% North Carolina (Boone)
% loading temperature data from 3 different locations
tempdat = load('StreamTemp.dat');
col1 = tempdat(:,1);
tempdat = tempdat-32;
tempdat = tempdat * 5;
tempdat = tempdat / 9;
tempdat(:,1) = col1;
% plot the data we converted
x = col1;
y = tempdat(:,2:4);
plot(x,y);
xlabel('Time(days)');
ylabel('Temperature(C)');
title('Temperature Gauges in North Carolina');
##### 1 CommentShowHide None
dpb on 20 Apr 2020
...
col1 = tempdat(:,1);
tempdat = tempdat-32;
tempdat = tempdat * 5;
tempdat = tempdat / 9;
tempdat(:,1) = col1;
The above just writes the same data back to column one of the tempdat array because variable col1 was never modified---what you're looking for is:
tempdat(:,1)=5*(tempdat(:,1)-32)/9; % convert FtoC column 1 tempdat array
But, you follow this with
x = col1;
y = tempdat(:,2:4);
plot(x,y);
so it looks like column 1 isn't a temperature after all but maybe a time variable???
The plot call you have will draw three lines in different colors so that part of the question should be answered.
What we need to know is what the actual data in the file is as what you've written seems inconsistent at best.

Sign in to comment.

### Answers (1)

Vimal Rathod on 23 Apr 2020
Hi,
If you try to plot any two timeseries plots in the same plot using "hold on" you would always get plots with different colors and that would be automatically done by MATLAB.
But if you want to specify which color each plot should have, you could refer to the following link to know more about the color property of plot.
To know more about "hold" refer to the following link
Refer to the below link for more details on plotting timeseries data
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Categories

Find more on Annotations 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!