Snakecharts in Matlab App Designer
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Andrea Quintarelli
am 7 Feb. 2025
Kommentiert: Andrea Quintarelli
am 11 Feb. 2025
Hi everyone,
I am trying to understand how to generate the kind of plot you can see in the picture attached.
What you basically have there is something like an horizontal histogram, where the important bit are the green bars (that do not start from "0" on their own scale or, in other words, need to be between a start and end value). Each of those bars would need to have different scale (different max and min values for the whole line and, inside those, the green bar).
On top of that, I would need to draw a line that goes through each bar and meet a point, on each bar. Each point need to be positioned horizontally respecting the same scale (min and max value) of each bar.
Do you have any idea on how I could get there?
Thank you very much!

0 Kommentare
Akzeptierte Antwort
Harald
am 7 Feb. 2025
Hi,
you can use a stacked barh and modify the colors. Modifying an example in the barh doc:
x = [1980 1990 2000];
y = [15 20 5; 10 17 21; 10 5 15];
b = barh(x,y,'stacked');
b(1).FaceColor = [0.5 0.5 0.5];
b(2).FaceColor = [0 0.5 0];
b(3).FaceColor = [0.5 0.5 0.5];
Adding the line on top after a hold on should not be too difficult, and text can be used for inserting the text.
Best wishes,
Harald
3 Kommentare
Harald
am 10 Feb. 2025
Hi Andrea,
Yes, you can add a line on top of barh.
x = [1980 1990 2000];
y = [15 20 5; 10 17 21; 10 5 15];
b = barh(x,y,'stacked');
b(1).FaceColor = [0.5 0.5 0.5];
b(2).FaceColor = [0 0.5 0];
b(3).FaceColor = [0.5 0.5 0.5];
hold on
plot([25 20 12], x, "r.-", "LineWidth", 2, "MarkerSize", 30)
hold off
I would implement "different scaling for each bar" by using multiple x-axes. Approaches for that are available on File Exchange, e.g. https://www.mathworks.com/matlabcentral/fileexchange/65044-plotmultix-varargin .
Best wishes,
Harald
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Discrete Data 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!