How can I create different colors in the plotted chart for a lot of data

72 ビュー (過去 30 日間)
Hello everyone;
I have huge data set, and i plotted for at least 70 different sets. What should I do to color all lines differently? What are your suggestions?
I thank everyone in advance
  2 件のコメント
Abidin Burak Nuzumlali
Abidin Burak Nuzumlali 2020 年 9 月 19 日
Hello, i know this function use varies line colours but i have very big data so after every 8 lines the colors return to the beginning



Turlough Hughes
Turlough Hughes 2020 年 9 月 20 日
I'm coming at this from a slightly different angle. You can interactively highlight different lines by setting up a slider in the live editor as per the demo I've attached. With this approach you can see all the other data while highlighting one line of interest at a time (in this case I just increase the linewidth and bring it to the front of the graph, though one could specify other line properties).
Advantages: You do not have to read down a list of 70 or more legend entries. You avoid any colour similarity issue, and furthermore, you ensure the line you want to assess is in the foreground; with 70 or more lines it is quite likely that many cover a large portion of the line you’re currently looking at.
  2 件のコメント
Abidin Burak Nuzumlali
Abidin Burak Nuzumlali 2020 年 9 月 21 日
Thank you for your advice. I solved my problem


その他の回答 (2 件)

Dana 2020 年 9 月 18 日
Are you trying to plot 70 different data series on the same plot? If so, Matlab's default color scheme won't give you 70 different colors. Instead, there are 7 colors that it cycles through, so you'll end up with 10 data series for each color.
You can create your own color order with as many colors as you want in it, but before you do, let me ask: are you sure you want to do that? 70 plots on one graph is...a lot.
If you're sure, then the easiest way is probably to pick a pre-set color map (see colormap), use it to generate 70 different colors, and then use colororder to apply it to your figure. So if X is a matrix with 70 columns, each containing one data series, something like:
N = size(X,2); % number of data series
plot(X) % plot your data
colororder(parula(N)) % pick N colors from the parula color map and use them
  4 件のコメント
Abidin Burak Nuzumlali
Abidin Burak Nuzumlali 2020 年 9 月 21 日
thank you for your advice


Adam Danz
Adam Danz 2020 年 9 月 20 日
Inspired by Turlough Hughes's slider used to chose a line object, here's a way to add info to each line's data tip so you can hover the mouse of any line to display the line info.
Here's another demo containing a series of gaussians and I've added the sigma (width) and amplitude (height) of each curve to the data tip. The data tip appears when you hover the mouse over the curve or if you click on the curve.
Modify the demo to add any information you want to the line.
% Plot 12 gaussians with different widths and heights
x = linspace(0,200,1000);
gaus = @(x,mu,sig,amp)amp.*exp(-(((x-mu).^2)./(2.*sig.^2)));
amp = linspace(10,12,8)';
sig = linspace(20,30,8)';
y = gaus(x,100,sig,amp);
h = plot(x,y');
% Add two rows to the data tips to show their sigma (width)
% and amp (height) values.
for i = 1:numel(h)
% Add a new row to DataTip showing the gaus parameters
h(i).DataTipTemplate.DataTipRows(end+1) = dataTipTextRow('Sigma',repmat({round(sig(i),2)},size(h(i).XData)));
h(i).DataTipTemplate.DataTipRows(end+1) = dataTipTextRow('Amp',repmat({round(amp(i),2)},size(h(i).XData)));
  5 件のコメント
Abidin Burak Nuzumlali
Abidin Burak Nuzumlali 2020 年 9 月 22 日
Turlough Hughes, As Adam Danz said, all 3 solution methods are a very efficient solution method. I have achieved a result by considering all your suggestions and blending them. So instead of comparing each other, I used all the answers.



Help Center および File ExchangeAnnotations についてさらに検索





Community Treasure Hunt

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

Start Hunting!

Translated by