How to plot with diferents colors
2 views (last 30 days)
Show older comments
Hello! I would like to differentiate types of filter and signals with and without noise, but I am not able to differentiate the noise part.
no_noise = plot(number_projections, SER_no_noise(:, :));
hold on;
with_noise = plot(number_projections, reshape(SER_with_noise(:, length(variance), :),...
[length(tests_to_run), length(number_projections)]));
h = [no_noise; with_noise];
legend(h, 'shep-logan NO NOISE','Cosine NO NOISE', 'ram-lak NO NOISE', 'Hann NO NOISE', 'Hamming NO NOISE',...
'shep-logan WITH NOISE','Cosine WITH NOISE', 'ram-lak WITH NOISE', 'Hann WITH NOISE', 'Hamming WITH NOISE')
0 Comments
Answers (2)
Ameer Hamza
on 29 May 2020
Edited: Ameer Hamza
on 29 May 2020
By default, the MATLAB axes only use seven colors to plot the lines. After that, the sequence is repeated if there are more then seven lines: https://www.mathworks.com/help/releases/R2020a/matlab/ref/matlab.graphics.axis.axes-properties.html#budumk7_sep_shared-ColorOrder. You can define your own colors to make them more distinguishable. For example
ax = axes()
ax.ColorOrder = rand(10,3); % define 10 rgb colors randomly. You can write your own matrix instead of using rand()
no_noise = plot(number_projections, SER_no_noise(:, :));
hold on;
with_noise = plot(number_projections, reshape(SER_with_noise(:, length(variance), :),...
[length(tests_to_run), length(number_projections)]));
h = [no_noise; with_noise];
legend(h, 'shep-logan NO NOISE','Cosine NO NOISE', 'ram-lak NO NOISE', 'Hann NO NOISE', 'Hamming NO NOISE',...
'shep-logan WITH NOISE','Cosine WITH NOISE', 'ram-lak WITH NOISE', 'Hann WITH NOISE', 'Hamming WITH NOISE')
0 Comments
See Also
Categories
Find more on Hamming 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!