Do floating bar graphs exist in matlab?

血红的双手。 提交于 2019-12-11 08:38:42

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!