Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 带误差条的成组绘图_Matlab_Plot_Matlab Figure_Legend_Errorbar - Fatal编程技术网

Matlab 带误差条的成组绘图

Matlab 带误差条的成组绘图,matlab,plot,matlab-figure,legend,errorbar,Matlab,Plot,Matlab Figure,Legend,Errorbar,我有下面的代码来绘制图: dfs = [0 5 10 15 20 25 ]; Intensities = [0.0593 0.0910 0.1115 0.0611 0.0975 0.0715] ; SE = [0.2165 0.2068 0.2555 0.2479 0.2340 0.2239]; errorbar(dfs, Intensities, SE, 'ro'); hold on plot(dfs,Intensities,'bo'); title('\fontsize{14}Inten

我有下面的代码来绘制图:

dfs = [0  5 10 15 20 25 ];
Intensities = [0.0593 0.0910 0.1115 0.0611 0.0975 0.0715] ;
SE = [0.2165 0.2068 0.2555 0.2479 0.2340 0.2239];

errorbar(dfs, Intensities, SE, 'ro');
hold on
plot(dfs,Intensities,'bo');
title('\fontsize{14}Intensities per condition');
hold off;

ylim([-0.2 0.5])

names = {'\fontsize{12}Cond1, Group1'; '\fontsize{12}Cond2, Group1'; '\fontsize{12}Cond1, Group2'; '\fontsize{12}Cond2, Group2'; '\fontsize{12}Cond1, Group3';'\fontsize{12}Cond2, Group3'};
set(gca, 'xtick', dfs, 'xticklabel', names);
xlim([-1 26]);  %just for better visualisation
ylabel('\fontsize{14}Intensities')
我想把点和它们的错误条成对地分组。因此点(点估计值)
1、3和5都属于条件1,而点
2、4和6
属于条件2。我的意思是应该有一些迹象表明
1,3,5
属于条件1,而
2,4,6
属于条件2,例如通过图例。但是
legend('Condition 1','Condition 2')
在这里不能正常工作。把所有的信息放在xaxis刻度上太多了。或者,也可以明确前两个属于组1,后两个属于组2等。

可以做些什么

为了区分,请更改点的颜色,并在图例中提及它们。 对于您的情况,如果有几个条件和许多组,最好在图例中使用条件(这是您第一次声明的所需结果)。但是,如果有几个组和许多条件,则最好在图例中使用组(您将其作为备选方案编写)

对于第一种情况,即少数条件和多个组,将
plot
命令替换为:

h(1) = scatter(dfs(1:2:end),Intensities(1:2:end),'o','filled');
h(2) = scatter(dfs(2:2:end),Intensities(2:2:end),'o','filled');
%filling the dots so that your eyes may not dodge you about the colors :D
%I choose 1:2:end and 2:2:end for the first and second lines since there seems to be
%an order. If there is no order, you can explicitly state that as: [1 3 5] or [2 4 6]
for k=1:3
    h(k) = scatter(dfs([2*k-1 2*k]),Intensities([2*k-1 2*k]),'o','filled'); 
end                    %     ^---------generalised the formula
然后删除更改
xticklabels
的行,并将图例用作:

legend(h,'condition1','condition2');
legend(h,'group1','group2','group3');

图1:条件较少,多组


对于第二种情况,即少数组和许多条件,将
plot
命令替换为:

h(1) = scatter(dfs(1:2:end),Intensities(1:2:end),'o','filled');
h(2) = scatter(dfs(2:2:end),Intensities(2:2:end),'o','filled');
%filling the dots so that your eyes may not dodge you about the colors :D
%I choose 1:2:end and 2:2:end for the first and second lines since there seems to be
%an order. If there is no order, you can explicitly state that as: [1 3 5] or [2 4 6]
for k=1:3
    h(k) = scatter(dfs([2*k-1 2*k]),Intensities([2*k-1 2*k]),'o','filled'); 
end                    %     ^---------generalised the formula
然后删除更改Xticklabel的行,并将图例用作:

legend(h,'condition1','condition2');
legend(h,'group1','group2','group3');


图2:更多的条件,更少的组

为了区分,改变点的颜色,并在图例中提及它们。 对于您的情况,如果有几个条件和许多组,最好在图例中使用条件(这是您第一次声明的所需结果)。但是,如果有几个组和许多条件,则最好在图例中使用组(您将其作为备选方案编写)

对于第一种情况,即少数条件和多个组,将
plot
命令替换为:

h(1) = scatter(dfs(1:2:end),Intensities(1:2:end),'o','filled');
h(2) = scatter(dfs(2:2:end),Intensities(2:2:end),'o','filled');
%filling the dots so that your eyes may not dodge you about the colors :D
%I choose 1:2:end and 2:2:end for the first and second lines since there seems to be
%an order. If there is no order, you can explicitly state that as: [1 3 5] or [2 4 6]
for k=1:3
    h(k) = scatter(dfs([2*k-1 2*k]),Intensities([2*k-1 2*k]),'o','filled'); 
end                    %     ^---------generalised the formula
然后删除更改
xticklabels
的行,并将图例用作:

legend(h,'condition1','condition2');
legend(h,'group1','group2','group3');

图1:条件较少,多组


对于第二种情况,即少数组和许多条件,将
plot
命令替换为:

h(1) = scatter(dfs(1:2:end),Intensities(1:2:end),'o','filled');
h(2) = scatter(dfs(2:2:end),Intensities(2:2:end),'o','filled');
%filling the dots so that your eyes may not dodge you about the colors :D
%I choose 1:2:end and 2:2:end for the first and second lines since there seems to be
%an order. If there is no order, you can explicitly state that as: [1 3 5] or [2 4 6]
for k=1:3
    h(k) = scatter(dfs([2*k-1 2*k]),Intensities([2*k-1 2*k]),'o','filled'); 
end                    %     ^---------generalised the formula
然后删除更改Xticklabel的行,并将图例用作:

legend(h,'condition1','condition2');
legend(h,'group1','group2','group3');


图2:更多的条件,更少的组

类似或?即使函数是方框图,错误条也应该类似。请指定
精度
。完成,谢谢Ander!或者什么?即使函数是方框图,错误条也应该类似。请指定
精度
。完成,谢谢Ander!