How do I get a bar chart in the newest version but with the colors from an older version?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Stacy Sidle
am 23 Mai 2019
Kommentiert: Stacy Sidle
am 23 Mai 2019
I am trying to regenerate a bar chart that was initially created using an older version of Matlab, but I am now using the 2019 version and the colors are completely different. I have not been able to locate a definitive answer to what the default colors are for a bar chart.
2 Kommentare
Geoff Hayes
am 23 Mai 2019
Stacy - perhaps show some of your code (in particular that which generates the bar chart). Also, show a screen shots (of the charts) contrasting the older version and 2019 version of MATLAB so that we can understand/see how the colours have changed.
Akzeptierte Antwort
Stephen23
am 23 Mai 2019
Bearbeitet: Stephen23
am 23 Mai 2019
"I have not been able to locate a definitive answer to what the default colors are for a bar chart."
The bar documentation states "Starting in R2017b, the default value is an RGB triplet from the ColorOrder property of the axes. In previous releases, the default value was 'flat' and the colors were based on the colormap", so clearly for version >=R2017b you will have to change the axes ColorOrder property rather than the figure/axes colormap.
Learn about the axes ColorOrder property by reading the documentation, e.g.:
Note that setting the axes ColorOrder is a little bit tricky as high-level plotting commands (e.g. plot, bar, etc.) reset most axes properties back to their defaults. You could change the default ColorOrder or change the axes NextPlot property to ReplaceChildren so that these properties are not reset.
For some examples of how to change the axes ColorOrder property see my FEX submission:
Note that there is absolutely no need to poke around with external utilities to get the previously used colors: as the documentation makes clear, earlier versions used the figures/axes colormap colors, which are of course available by simply calling the appropriate colormap function (or even obtained from the saved .fig files). The default colormaps are:
- <R2014b jet
- >=R2014b parula
So you should try something like this:
ax = axes('ColorOrder',parula(7),'NextPlot','replacechildren');
bar(ax,...)
Weitere Antworten (1)
the cyclist
am 23 Mai 2019
There are utilities (e.g. "Digital Color Meter" on a Mac) where you can hover your cursor over a pixel on the screen, and it will report the RGB value of that pixel. Assuming you have a copy of the old figure on your computer, that would allow you to identify the exact colors, which you can then replicate in the new version of MATLAB.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!