Assigning colours to many lines in a single plot

7 views (last 30 days)
Hi I have made a GUI which contains a button to import any number of text files containing x and y data, and then plot them all on a single axes.
each line is assigned a random colour:
colour=round(random('unif',0,200,1,3))/255;
However, I now want to go about assigning colours to these lines in a logical way. The way I would like to do it is for the first file to be plotted as the first colour of the RGB spectrum (red) and the last file to be plotted as the last colour of the RGB spectrum (blue). And then all the files in between to be assigned colours at equally spaced points in the spectrum. e.g. If 7 files are imported, the first would be plotted with a red line, the second with an orange line etc.. and then say if 700 files were imported, the first 100 would all be a shade of red and the next 100 a shade of orange etc... I am hoping you understand what I mean!
Is there a way to do this on matlab? I would really appreciate your help.
I think there may be some numbers/ vectors involved in this, but unfortunately my maths skills are quite poor!
Thanks in advance
Vera

Accepted Answer

Star Strider
Star Strider on 21 Feb 2015
Use the colormap function. In your application, colormap(jet(700)) would seem to be appropriate.
  2 Comments
VeraM
VeraM on 22 Feb 2015
Thank you very much :) colormap seems promising!
Star Strider
Star Strider on 22 Feb 2015
My pleasure!
It’s worked well for me in the past.

Sign in to comment.

More Answers (0)

Categories

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