Change plot color long/shortnames to new default colors.
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
William Wooley
il 28 Dic 2015
Risposto: Christian Claumarch
il 17 Lug 2018
Suppose I want to make a plot where a later series has the same color as an earlier series, which is plotted in one of the default colors.
Intuitively, one would do something like this:
n = 10;
a = rand(n,1);
b = rand(n,1);
w = 1e-1;
p = 1:n;
plot(p,a,p,b,p,a+w,'b',p,b+w,'r','LineWidth',3);
However, the 'b'lue and 'r'ed in the second two plots aren't the default blue and red. (I believe that they are the old defaults?). My question is: Can I set the long/shortnames (e.g. 'b', 'r') so that they are the new default colors?
Perhaps I should add that I know that I can achieve the same effect by providing the RGB triple for the default color needed. For forgetful people like me, though, that adds maybe two more steps each time I want to do this.
0 Commenti
Risposta accettata
Vineeth Kartha
il 4 Gen 2016
Hi,
It is not possible to change the RGB values set for the long/shortnames. But as a workaround you can try saving the RGB values of the new default colors, and use these variables to specify the color.
the following command can be used to get the RGB value of the default colors
color=get(gca,'ColorOrder')
This will return a 7x3 matrix with the RGB value of the seven new default colors.
then use the values in each row to specify color to your graph.
x=rand(1,10);
y=rand91,10);
plot(x,y,'Color',color(1,:))
Più risposte (1)
Christian Claumarch
il 17 Lug 2018
Depending on what you are aiming to do with this functionality this might help: Restart color order.
data = [5 6 7; 2 3 4; 4 5 6];
plot(data);
hold on
ax = gca;
ax.ColorOrderIndex = 1;
plot(3*data);
hold off
In a case where you want to show the same data before and after treatment in the same color in the same plot this does the trick. If you want to fully control the color the previous answer is better.
0 Commenti
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!