问题
I'm trying to make a simple bar graph that would essentially look like the following horrible ASCII rendering:
Y
| ----------
| ---
| -----
| --
| -------
|______________ X
5 6 7 8 9
Is this possible? I haven't found a way to do it.
回答1:
If you know exactly the coordinates of the desired bars in the graph, and the width of each bar line, you can do somthing like that:
a=[5 10; 5 23; 7 13; 6 18]; % each pair is a start point of bar
L=0.1; %Bar width
for i=1:size(a,1)
plot([a(i,1) a(i,1)+L], [a(i,2) a(i,2)])
hold on
ylim([ 9 24])
end
where in a
you put the coordinates, and L
is the bar length.
来源:https://stackoverflow.com/questions/17460394/do-floating-bar-graphs-exist-in-matlab