Does anyone know how can I create the colours brown,violet and orange?

Hello everyone,
I would like to change the colors "yellow" into brown, violet and orange in my script (obviously, in three different lines)
yyaxis right
plot(year.DateA, year.year_values,'y-^' ,'MarkerEdgeColor','k','MarkerFaceColor','y')
How can I do it?
Thank you!

 Accepted Answer

My best attempts —
brwn = [200 100 16]/256;
vlet = [160 81 151]/256;
orng = [240 100 10]/256;
figure
patch([0 1 1 0], [0 0 1 1], brwn)
hold on
patch([0 1 1 0]+1, [0 0 1 1], vlet)
patch([0 1 1 0]+2, [0 0 1 1], orng)
hold off
.

12 Comments

Thank you!
Is it possible to create a darker brown and violet?
As always, my pleasure!
Is it possible to create a darker brown and violet?
Possibly, although that would requrie some experimentation to see what works best. The easiest way to do that would be to change the 256 constant to something larger or smaller (however not to exceed the largest value in the associated vectors, since they are limited to the interval (0,1)). That would likely change the colours as well, so this could be an iterative process to get the ‘correct’ hue and saturation.
.
okay, thank you!
But how can I keep the triangle in the plot, if I put this new color?
Something like this?
vlet = [160 81 151]/256;
patch([0 1 1 0]+1, [0 0 1 1], vlet)
hold on
yyaxis right
plot(year.DateA, year.year_values,'-^' ,'MarkerEdgeColor','k','MarkerFaceColor')
As always, my pleasure!
I do not understand ‘triangle’ in this context.
I would imagine something like this —
brwn = [200 100 16]/256;
vlet = [160 81 151]/256;
orng = [240 100 10]/256;
x = 1:10;
y = rand(size(x));
figure
plot(x, y, '^-', 'Color',brwn, 'MarkerEdgeColor',orng, 'MarkerFaceColor',vlet, 'MarkerSize',10)
grid
I enlarged the markers to show the differences between the face and edge colours.
.
I would use the uisetcolor tool to visually select the color that I wanted. It will return the RGB triplet for that color which you can then use as the value of a color property of the appropriate Handle Graphics or UI object.
@Steven Lord — Definitely useful! I had no idea that funciton existed.
@Steven Lord Thank you very much! The only problem is that when I try to use it, it doesn't work!
For the record, uisetcolor worked correctly when I tried it just now. (I also scrolled down its documentation to discover that it’s been part of MATLAB since before R2006a, and I didn’t previously know about it!)
I don't know why it doesn't work on my MATLAB; I have MATLAB 2021a!
The usual first approach to something like this is to re-start MATLAB and try it again.

Sign in to comment.

More Answers (1)

Yes, I tried, but it didn't work.

4 Comments

Sorry.
The next approach is to un-install and re-install MATLAB.
Painful, although apparently necessary.
If that also fails, Contact Support and include the URL of this thread so MathWorks knows what you already attempted.
You have my sympathies!
.
Okay, thank you very much for your help and tips!
As always, my pleasure!
Please follow up when you get this working, and describe what the eventual solution turned out to be. I am curious, and others can likely benefit.
.

Sign in to comment.

Asked:

Pul
on 6 Nov 2021

Commented:

Pul
on 8 Nov 2021

Community Treasure Hunt

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

Start Hunting!