如何在Matlab中为条形图添加数据标签 [英] how to add data labels for bar graph in matlab

查看:1980
本文介绍了如何在Matlab中为条形图添加数据标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如(代码):

x = [3 6 2 9 5 1];
bar(x)

为此,我需要在每个栏的顶部添加数据标签. 我知道我必须使用TEXT关键字,但是我没有获得实现它的方法.

for this I need to add data labels on top of the each bar. I know that I have to use TEXT keyword, but I'm not getting how to implement it.

推荐答案

这是使用text的简单解决方案:

Here is a simple solution with text:

x = [3 6 2 9 5 1];
bar(x)
ylim([0 max(x)*1.2])
text(1:numel(x),x+0.5,num2cell(x))

这篇关于如何在Matlab中为条形图添加数据标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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