
How can I change the color of the median line in boxplot?
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 3 Aug. 2015
Beantwortet: MathWorks Support Team
am 3 Aug. 2015
I am creating a box plot using the "boxplot" function (in the Statistics and Machine Learning Toolbox) as follows:
x = magic(3);
boxplot(x);
The plot generated looks like this with red lines in the center:

How can I change the red color of the median line to something else?
Akzeptierte Antwort
MathWorks Support Team
am 3 Aug. 2015
In order to change the color property of these median lines, we can use the "findobj" function to locate these lines, and then set their color to green. This can be achieved by adding the following lines of code after creating the boxplot:
lines = findobj(gcf, 'type', 'line', 'Tag', 'Median');
set(lines, 'Color', 'g');
This will change the color of these lines to green, as shown below:

0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!