3

请考虑 :

Needs["ErrorBarPlots`"];

fixNumberF1F6 = {{{7.11`, 7.51`, 11.14`, 8.19`, 6.58`}, 
                  {2.14`, 2.33`,2.25`, 1.53`,1.71`}},               
                  {{4.69`, 4.79`, 3.78,4.34`, 4.8`}, 
                   {2.22`, 2.71`, 3.18`, 2.29`, 1.93`}}}

fixNumberF1F6[[1,1]] 是指条件 1 下每个主题的平均注视数, fixNumberF1F6[[1,2]] 是这些均值的标准偏差。fixNumberF1F6[[2]] 指的是条件 2。

plotOptionsXX[title_, yName_, xName_, colors_: Black] :=

  {Frame -> {{True, False}, {True, False}},
   PlotStyle -> colors,
   PlotLabel -> 
   Style[title, Bold, 14, Opacity[1], FontFamily -> "Helvetica"],
   PlotStyle -> Directive[Black, PointSize[Medium]],
   PlotRangePadding -> 0,
   Frame -> {{True, False}, {True, False}},
   LabelStyle -> Directive[Black, Bold, 12],
   FrameLabel -> {{Style[yName, Opacity[1]], 
   None}, {Style[xName, Opacity[1]], None}},
   FrameStyle -> Opacity[0],
   FrameTicksStyle -> Opacity[1],
   AxesStyle -> Directive[Black, 12],
   ImageSize -> laTaille};

ErrorListPlot[fixNumberF1F6[[#]] // Transpose,
              PlotRange -> {{0, 6}, {0, 15}},
              ImageSize -> 300,
              FrameTicks ->{{Range[1, 13, 2], None},{{1, 2, 3, 4, 5}, None}},
              PlotStyle -> Directive[Black, AbsolutePointSize[10], AbsoluteThickness[2]],
              plotOptionsXX["Mean Fixation number", "Fixation Nuber", "SubNo"]] & /@ Range[2]

在此处输入图像描述

左边的图表示每个受试者的平均注视数以及条件 1 的标准偏差。右边的条件 2。

我怎么能把它们都画在 1 个地块上?

如果这 :

fixNumberF1F6across = {{8.10, 1.99}, {4.48, 2.46}}

是跨主题的平均值和 SD,我怎么能同时显示?

- 我如何在不同主题的相似图上显示 2 个条件 - 我如何在其上显示组平均值和 SD。

4

4 回答 4

5

编辑

我从头开始。ListPlot考虑到数据的简单和干净,使用和添加条可能是最简单的Epilog

您仍然可以稍微调整一下——例如,在蓝色和红色数据点和条形之间留一点空间,添加一个图例等,但基本思想就在那里。

data = {{{7.11`, 7.51`, 11.14`, 8.19`, 6.58`}, {2.14`, 2.33`, 2.25`,   1.53`, 1.71`}}, {{4.69`, 4.79`, 3.78, 4.34`, 4.8`}, {2.22`,  2.71`, 3.18`, 2.29`, 1.93`}}};

ListPlot[{data[[1, 1]], data[[2, 1]]},
   PlotStyle -> {{PointSize[.025], Red}, {PointSize[0.025], Blue}},
   Frame -> True, 
   PlotRange -> {{0.5, 5.5}, {0, 14}},
   FrameTicks -> {{Automatic, Automatic}, {Range[5], None}},
   FrameLabel -> {{"Fixation (ms)", None}, {"Subject", None}},
   Epilog -> {{Red, Thickness[0.003], Dashed, 
      Line[{{0, m1 = Mean@data[[1, 1]]}, {5.5, m1}}],
      Blue, Line[{{0, m1 = Mean@data[[2, 1]]}, {5.5, m1}}]},
      Thickness[0.005], Red, 
      Line[{{#[[1]], #[[2, 1]]}, {#[[1]], #[[2, 2]]}}] & /@ 
      Transpose@{Range[5], ({#[[1]] + #[[2]], #[[1]] - #[[2]]} & /@ 
      Transpose@data[[1]])},
      Thickness[0.005], Blue, 
      Line[{{#[[1]], #[[2, 1]]}, {#[[1]], #[[2, 2]]}}] & /@ 
      Transpose@{Range[5], ({#[[1]] + #[[2]], #[[1]] - #[[2]]} & /@ 
      Transpose@data[[2]])},
      }]

晶须1

以下BoxWhiskerChart来自您的数据。如果这看起来有点像您感兴趣的东西,则可以对其进行修改,以便改变从 25% 到 75% 的范围,以反映高于和低于平均值的一个 sd 的分布。

而且,是的,很容易将组均值 (N=5) 叠加到图表上。

[在平均值周围没有完美对称的原因是我使用你的平均值和标准差来生成原始数据,假设是正态分布。每次试验我只使用了 100 个数据点,所以有点偏斜是很自然的。如果我们调整图表以反映对称的标准偏差,则不会发生这种情况。]

箱须图

于 2011-09-21T22:21:25.947 回答
5

对于任意数量的系列:

plotseries[a_] := 
 Module [{col = ColorData[22, "ColorList"]}, 
  Plot[Evaluate@(Piecewise[{#[[2]], #[[1]] - 1/3 <= x <= #[[1]] + 1/3} & /@ 
           Thread[List[Range@Length@#, #]]] & /@ 
              ({a[[#, 1]] + a[[#, 2]], a[[#, 1]] - a[[#, 2]]}) & /@ 
                (Range@Length@a)), {x, 0, 1 + Length@(a[[1, 1]])}, 
   ClippingStyle -> None,
   PlotStyle -> {None},
   Exclusions -> False,
   Filling -> ({2 # - 1 -> {{2 #}, Directive[col[[#]], Opacity[.2]]}} & /@ 
             Range@Length@a),
   Ticks -> {Range@Length[a[[1, 1]]], Range@#2 &},
   AxesLabel -> {Style["Subject", Medium, Bold], Style["Fixation Time", Medium, Bold]},
   Epilog -> 
    MapIndexed[{Directive[col[[#2[[1]]]], PointSize[.03]], 
       Point@Thread[List[Range@Length[#1[[1]]], #1[[1]]]]} &, a]
   ]
  ]
  b = Table[{Table[j^(i/3) + i, {j, 6}], Table[1, {j, 6}]}, {i, 1, 3}];
  plotseries[b]

在此处输入图像描述

于 2011-09-22T01:58:43.567 回答
4

我不太使用错误图,所以这很可能是一种显示数据的非标准形式,并根据ErrorBarFunction.

(*split it up so it's easier to follow*)
meanCond1 = fixNumberF1F6[[1, 1]];
stdCond1 = fixNumberF1F6[[1, 2]];
meanCond2 = fixNumberF1F6[[2, 1]];
stdCond2 = fixNumberF1F6[[2, 2]];

x1 = Transpose@{meanCond1, meanCond2};
x2 = ErrorBar @@@ Transpose@{stdCond1, stdCond2};

Show@(ErrorListPlot[{#1},
     ErrorBarFunction -> 
      Function[{coords, errs}, {Opacity[0.2], EdgeForm[{#2}], 
        Rectangle[coords + {errs[[1, 1]], errs[[2, 1]]}, 
         coords + {errs[[1, 2]], errs[[2, 2]]}]}], PlotStyle -> #2, 
     Axes -> False, Frame -> True, 
     FrameLabel -> {"Condition 1", "Condition 2"}] & @@@ 
   Transpose@{Transpose@{x1, x2}, {Blue, Yellow, Green, Gray, Red}})

在此处输入图像描述

每个点都是不同的主题。x坐标是条件 1 的平均值,坐标y是条件 2 的平均值。矩形边的长度是各自的标准偏差。因此,虽然它确实重叠,但如果您在选择颜色时谨慎(并且如果没有太多主题),它可能会起作用。

于 2011-09-21T22:21:30.520 回答
3
ErrorListPlot[Transpose /@ fixNumberF1F6, 
   PlotRange -> {{0, 6}, {0, 15}}, ImageSize -> 300, 
   FrameTicks -> {{Range[1, 13, 2], None}, {{1, 2, 3, 4, 5}, None}}, 
   PlotStyle -> 
       {
        Directive[Opacity[0.6],Black, AbsolutePointSize[10], AbsoluteThickness[2]], 
        Directive[Opacity[0.6],Gray, AbsolutePointSize[10], AbsoluteThickness[2]]
       }, 
   plotOptionsXX["Mean Fixation number", "Fixation Number", "SubNo"]
]

在此处输入图像描述

ErrorListPlot[fixNumberF1F6across, PlotRange -> {{0, 3}, {0, 15}}, 
    ImageSize -> 300, 
    FrameTicks -> {{Range[1, 13, 2], None}, {{1, 2}, None}}, 
    PlotStyle -> Directive[Black, AbsolutePointSize[10], AbsoluteThickness[2]], 
    plotOptionsXX["Mean Fixation number", "Fixation Number", "Condition Number"]
]

在此处输入图像描述

至于3号。如果要显示各个主题的数据,我看不出如何谈论组均值。第 4 个(第 5 个?)问题完全不清楚。我建议您删除这些问题,因为它们似乎并不特定于 Mathematica 编程。

于 2011-09-21T22:12:04.220 回答