如何将条形图的XtickLabels移到左侧? [英] How to shift the XtickLabels of a bar graph to the left?

查看:55
本文介绍了如何将条形图的XtickLabels移到左侧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试创建频率直方图,为此,我必须创建一个条形图,在条形之间没有空格.但是,这会将 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆