Stackedplot of a multi-column tametable: how to plot each line with a different color
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Corymbiamaculata
el 25 de Feb. de 2019
Comentada: Corymbiamaculata
el 1 de Mzo. de 2019
I have a timetable with multi-column variables (12 variables in each column). When using stackedplot, all variables from a given multi-column are plotted with the same colour. Is there any way to change that? I created a custom 12x3 color matrix - this doesn't work as...
Color value must be a 3 element vector
I then tried creating a 1:12 loop with 'hold on', but...
Using hold with stackedplot is not supported.
Is there any way to change that or should I simply use the good old plot function?
0 comentarios
Respuesta aceptada
Geoff Hayes
el 26 de Feb. de 2019
You may be able to change the colours of each line after you have called stackedplot. For example, you might (and I say might because my version of MATLAB doesn't support this function) be able to do the following
myColours = ...; % this is your 12x3 matrix of colours (one for each line)
s = stackedplot(...); % passing in your timetable data; s is a handle to the stacked plot
for k = 1:length(s.LineProperties)
if k <= size(myColours,1)
s.LineProperties(k).Color = myColours(k,:);
end
end
The above assumes that you can iterate over each plot object and change its colour...which the documentation seems to suggest that you can do. Also, one of the examples includes a legend which, when used, seems to change the line colours too.
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!