绘制不同的条件和在 Mathematica 中同时处理多个主题

发布于 2024-12-05 16:53:09 字数 1798 浏览 1 评论 0原文

请考虑:

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}}

是跨主题的平均值和标准差,我如何才能同时显示两者?

-如何在不同主题的相似图上显示 2 个条件 -我怎样才能向其显示该组的平均值和标准差。

Please Consider :

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]] refers to the mean fixation number for each subject for condition 1,
fixNumberF1F6[[1,2]] the standard Deviation of those means.
fixNumberF1F6[[2]] refers to condition 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]

enter image description here

The Plot On the Left represent each subject average fixation number along with the standard deviation for condition 1. On the right for condition 2.

How could I plot them both on 1 plot ?

If this :

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

was the mean and SD across subject, How could I show both ?

-How can I show 2 conditions on a similar plot for different subjects
-How could I show the group mean and SD on it to.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

孤云独去闲 2024-12-12 16:53:09

编辑

我从头开始。鉴于数据简单干净,使用 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]])},
      }]

whisker1

下面的 BoxWhiskerChart 来自您的数据。如果这看起来模糊地像您感兴趣的东西,则可以对其进行修改,以便更改从 25% 到 75% 百分位的分布,以反映高于和低于平均值 1 个标准差的分布。

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

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

BoxWhiskerChart

Edit:

I started from over. Given how the data are simple and clean, it may be easiest to use ListPlot and
add the bars via an Epilog.

You can still tweak it a bit--e.g. put a slight space between the blue and red data points and bars, add a legend, etc, but the basic idea is there.

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]])},
      }]

whisker1

The BoxWhiskerChart below is from your data. If this looks vaguely like something you are interested in, it could be modified so that the spread from the 25th percentile to the 75% percentile is altered to reflect the spread of one s.d. above and below the mean.

And, yes, it is easy to overlay the group means (N=5) onto the Chart.

[The reason there isn't perfect symmetry around the mean is that I used your means and standard deviations to generate raw data, assuming a normal distribution. I only used 100 data points per trial, so a little skewing is natural. This would not happen if we were to tweak the chart to reflect standard deviations, which are symmetrical.]

BoxWhiskerChart

单调的奢华 2024-12-12 16:53:09

对于任意数量的系列:

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]

在此处输入图像描述

For any number of series:

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]

enter image description here

国际总奸 2024-12-12 16:53:09

我不太擅长处理错误图,因此这很可能是一种非标准的数据显示形式,并根据 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 的平均值。矩形边长是各自的标准差。因此,虽然它确实重叠,但如果您谨慎选择颜色(并且没有太多主题),它也许会起作用。

I don't work very much with error plots, so this might very well be a non-standard form of displaying the data and hastily put together based on the example in the documentation for 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}})

enter image description here

Each dot is a different subject. The x coordinate is the mean for condition 1 and the y coordinate is the mean for condition 2. The lengths of the sides of the rectangles are the respective standard deviations. So while it does overlap, if you're prudent in choosing colors (and if there aren't too many subjects), it could perhaps work.

明月夜 2024-12-12 16:53:09
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"]
]

至于第三个。如果你想显示单个受试者的数据,我不明白你如何谈论群体手段。第四(第五?)问题完全不清楚。我建议您删除这些问题,因为它们似乎并不特定于 Mathematica 编程。

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"]
]

enter image description here

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"]
]

enter image description here

As to the 3rd. I don't see how you can talk about group means if you want to show the data of the individual subjects. The 4th (5th?) question is totally unclear. I suggest you remove those questions as they don't seem to be specific to Mathematica programming.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文