如何将条形图的XtickLabels移到左侧? [英] How to shift the XtickLabels of a bar graph to the left?
问题描述
我目前正在尝试创建频率直方图,为此,我必须创建一个条形图,在条形之间没有空格.但是,这会将 XTickLabels
居中在条的中间.由于这是一个直方图,我希望数值位于每个条形图之间的直线上,以便可以直观地指示间隔.本质上,我需要将所有刻度标签向左移动.
我正在使用R2016a.
浏览Mathworks只能找到有关如何使用折线图,散点图等的答案.
使用
此外,如果您有兴趣,可以更改刻度线的方向向外:
set(gca,'TickDir','out')
I'm currently trying to create a frequency histogram, and to do this, I had to create a bar graph that has no whitespace between the bars. However, this centers the XTickLabels
in the middle of the bars. Since it's a histogram, I would like the numerical values to be at the line between each bars so that it can visually indicate intervals. Essentially, I need to shift all the tick labels to the left.
I'm using R2016a.
Looking through Mathworks only turned up answers for how to do this using line graphs, scatter plots, etc.
Use the Style
argument of bar
to set it to histc
.
v = [6 12 17 21 28 25 19 15];
bar(v,'histc');
which gives:
Furthermore, if you're interested you can change the direction of tick marks to outwards with:
set(gca,'TickDir', 'out')
这篇关于如何将条形图的XtickLabels移到左侧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!