Matlab中是否存在浮动条形图?
问题描述:
我正在尝试制作一个简单的条形图,该条形图看起来基本上类似于以下可怕的ASCII渲染:
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.
答
如果您确切了解图形中所需条形的坐标以及每条条形线的宽度,则可以执行以下操作:
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
在a
中放置坐标,而L
是钢筋长度.
where in a
you put the coordinates, and L
is the bar length.