How to plot Gaussian in purple

9 views (last 30 days)
MG
MG on 13 Nov 2015
Commented: MG on 13 Nov 2015
Hi. I am plotting several Gaussians. I want to make the black line be purple instead, with a linewidth of 1.5. But I don't know how to do that. I know you have to use a vector, but all the vectors I tried don't work and I'm not getting purple, and that also screws up my linewidth too. MakeNormalDis is a function which links to another .m file which specifies a normal distribution function, for inputs mu and sigma. I am using R2014b version of matlab.
firstp = makeNormalDis(0,1.5);
secondp = makeNormalDis(0,1);
thirdp = makeNormalDis(0,3);
fourthp = makeNormalDis(0,0.5);
x = [-5,5];
% Plot the results:
figure;
hold on
fplot(firstp, x, 'b');
set(findobj(gca, 'Type', 'Line', 'Color', 'b'), 'LineWidth', 1.5);
fplot(secondp, x, 'r');
set(findobj(gca, 'Type', 'Line', 'Color', 'r'), 'LineWidth', 1.5);
fplot(thirdp, x, 'y');
set(findobj(gca, 'Type', 'Line', 'Color', 'y'), 'LineWidth', 1.5);
fplot(fourthp, x, 'k');
set(findobj(gca, 'Type', 'Line', 'Color', 'k'), 'LineWidth', 1.5);
ylabel('pdf(x)');
xlabel('x');
title('Probability Density Function');
legend('mu = 0, sigma = 1.50', 'mu = 0, sigma = 1.00', ...
'mu = 0, sigma = 3.00', 'mu = 0, sigma = 0.50', ...
'Location', 'northeast');
hold off

Answers (1)

Image Analyst
Image Analyst on 13 Nov 2015
See if a color of 'm' works for you. Otherwise use 'Color', [0.5,0,0.5] or something like that to make it a little darker.
  1 Comment
MG
MG on 13 Nov 2015
m makes it magenta.
The part I am not sure I understand is where to put the vector.
Before, I changed that line to look like this:
fplot(fourthp, x, 'Color', [0.5,0,0.5]);
set(findobj(gca, 'Type', 'Line', 'Color', [0.5,0,0.5]), 'LineWidth', 1.5);
But matlab didn't like that. I also tried to specify the color vector only in "set", but that didn't work either. What am I doing wrong?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!