bar用法 matlab,matlab bar的用法简介

本文介绍了如何在Matlab中创建美观的条形图,特别是使用`bar`命令和`barwitherr`函数来展示带有误差棒的数据。通过示例展示了如何为两个不同菌株在四种实验条件下的数据创建条形图,并调整颜色、误差棒和轴标签。
摘要由CSDN通过智能技术生成

Summary

This explains the basics of making pretty bar plots in Matlab. The Matlab "bar" command is used, along with some nice scripts discovered on the Matlab file exchange.

Example

Suppose you have some experimental data from two strains (Strain 1 and Strain 2) under four different experiment conditions (Condition A,B,C,D). The means and standard deviations of your measurement of interest look like:

Strain1_Mean=[0.5137 3.2830 1.5887 5.9188];

Strain2_Mean=[0.4042 2.9884 0.5709 2.7766];

Strain1_std=[1.1393 2.8108 2.2203 3.5233];

Strain2_std=[0.8762 2.8478 0.9878 2.2197];

Use Matlab's bar command to plot this data (without error bars) as a bar chart:

bar([1 2 3 4],[Strain1_Mean' Strain2_Mean'])

legend('Strain 1','Strain 2')

pause; close all;

7f2b7868230934d9185e9e8933c2e433.png

This looks ok, but we would really like some error bars, so we use a handy function (barwitherr) from the Matlab file exchange:

h=figure; hold;

barwitherr([Strain1_std' Strain2_std'], [1 2 3 4],[Strain1_Mean' Strain2_Mean'])

legend('Strain 1','Strain 2')

pause; close all;

bc6671adba733d4c707e1b2ed25b32b2.png

This is ok, but we'd rather only have one-sided error bars. To do this, use a 4x2x2 matrix for the

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值