用Matlab画直方图
2016-03-25 19:38
453 查看
简介
本文介绍如何使用matlab定制自己的直方图。关键
使用Matlab的bar()函数创建柱状图
bar()画的bin的高度跟数据相关
bar()数据每一列一个group,有几列数据就画出几组柱状图
坐标轴显示的刻度叫 XTick 或 YTick
注意gca和gcf的区别,可以doc他们分别查看相关说明
示例代码
close all; clc clear; % bins data num_bins = 5; num_methods = 3; data = rand(num_bins, num_methods); % draw the graph figure; handle_bar = bar(data); ax = gca; % tight the graph axis tight; % title and labels title('\bf\color[rgb]{0,0,0}histgram'); xlabel('$\mathbf{\Gamma(x)}$ \textbf{value}', 'Interpreter', 'latex'); %xlabel('\bf\color[rgb]{0,0,0}\Gamma(x)', 'Interpreter', 'tex'); ylabel('\bf\color[rgb]{0,0,0}percentage'); % ytick : add % and use Bold Font with the TeX Interpreter ytick = ax.YTick; ytick_label = cell(length(ytick), 1); for i = 1:length(ytick) ytick_label(i) = {['\bf', num2str(ytick(i)*100), '%']}; end ax.YTickLabel = ytick_label; % Grid ax.YGrid = 'on'; % legend leg_handle = legend('\bf{}method 1', '\bf{}method 2', '\bf{}method 2', 'Location', 'northeast'); % figure position and size : [left bottom width height] set(gcf, 'Position', [100, 500, 400, 260]);
效果
相关文章推荐
- matlab基本知识点3-单元数组与结构
- ubuntu 安装Matlab 解决显示中文乱码
- Apriori算法Matlab实现
- k-Mediods算法Matlab实现
- k-Means算法Matlab实现
- Matlab图像处理学习笔记(一):二值化、开操作、连通区域提取、重心、ROI
- Matlab-猜数游戏
- Hough变换检测椭圆 附带matlab与opencv代码
- 将matlab处理结果保存为图像文件
- matlab vs python
- matlab标准化和反标准化——zscore
- 通过数据得到拟合数据并制图
- matlab 曲线拟合
- matlab 曲线拟合
- 【matlab应用】:生成老电影海报
- 【matlab】:matlab如何让一张图里面能画多个控件?
- 【matlab】:matlab中如何三维画球?
- Matlab支mean函数repmat函数
- libsvm for matlab安装与测试
- 【matlab】:matlab的linspace函数解析