4
$\begingroup$

This is the code I have working for a single set of data. Is there a way I can structure this to have multiple sets of data?

title = "Preliminary - Altering Blade Angle";
ylabel = "Voltage (V ± 0.05)";
xlabel = "Blade Angle (° ± 3)";
avg = {{10, 0.662}, {20, 0.96}, {30, 0.916}, {40, 0.787}, {50, 
    0.621}, {60, 0.453}};
min = {{0.55`}, {0.91`}, {0.85`}, {0.72`}, {0.58`}, {0.42`}};
max = {{0.76`}, {1.02`}, {0.99`}, {0.85`}, {0.68`}, {0.51`}};

data = MapThread[{#1, 
     ErrorBar[{#2[[1]] - #1[[2]], #3[[1]] - #1[[2]]}]} &, {avg, min, 
    max}];

Needs["ErrorBarPlots`"];
ErrorListPlot[data, Joined -> True, InterpolationOrder -> 2, 
 Mesh -> Full, PlotMarkers -> Automatic, 
 AxesLabel -> {xlabel, ylabel}, GridLines -> Automatic, 
 GridLinesStyle -> Dotted, PlotLabel -> Style[title, Bold], 
 LabelStyle -> (FontFamily -> "Helvetica"), PlotRange -> All, 
 ImageSize -> 600]

Maybe I could do something like this:

Needs["ErrorBarPlots`"];
title = {{"Preliminary - Altering Blade Angle"}, {"experiment 2"}};
ylabel = {{"Voltage (V ± 0.05)"}, {"ylabel 2"}};
xlabel = {{"Blade Angle (° ± 3)"}, {"xlabel 2"}};
avg = {
   {{10, 0.662}, {20, 0.96}, {30, 0.916}, {40, 0.787}, {50, 
     0.621}, {60, 0.453}},

   {{5, 0}, {10, 0.564`}, {15, 0.795`}, {20, 0.903`}, {25, 
     0.933`}, {30, 0.908`}, {35, 0.844}}
   };
min = {
   {{0.55`}, {0.91`}, {0.85`}, {0.72`}, {0.58`}, {0.42`}},
   {{0}, {0.52`}, {0.74`}, {0.78`}, {0.8`}, {0.84`}, {0.78}}
   };
max = {{{0.76`}, {1.02`}, {0.99`}, {0.85`}, {0.68`}, {0.51`}},
   {{0}, {0.6`}, {0.84`}, {0.98`}, {1.06`}, {0.97`}, {0.92}}
   };

for the first part? I'm not sure how to structure the second part.

$\endgroup$
5
$\begingroup$

Perhaps just

Needs["ErrorBarPlots`"];
data[i_] := MapThread[{#1, ErrorBar[{#2[[1]] - #1[[2]], #3[[1]] - #1[[2]]}]} &, 
                    {avg[[i]], min[[i]], max[[i]]}];

Framed@Column[
  ErrorListPlot[data@#, Joined -> True, InterpolationOrder -> 2, 
     Mesh -> Full, PlotMarkers -> Automatic, 
     AxesLabel -> {xlabel[[#,1]], ylabel[[#,1]]}, GridLines -> Automatic, 
     GridLinesStyle -> Dotted, PlotLabel -> Style[title[[#,1]], Bold], 
     LabelStyle -> (FontFamily -> "Helvetica"), PlotRange -> All, 
     ImageSize -> 600] & /@ Range@Length@avg]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Thanks, I tried this but it threw up a lot of errors cl.ly/image/2L2C2t1l300k $\endgroup$ – Theo Oct 27 '12 at 22:27
  • $\begingroup$ @TheoWindebank Works Ok. here. Perhaps a version problem. Before going deeper, shut down mathematica and run it in a fresh session. $\endgroup$ – Dr. belisarius Oct 27 '12 at 22:33
  • $\begingroup$ Well that's strange, it appears to work after restarting it and using a new notepad. Thanks for your help. What do you think could have caused that to happen? $\endgroup$ – Theo Oct 27 '12 at 22:38
  • $\begingroup$ @TheoWindebank Typically, some previous definition of data $\endgroup$ – Dr. belisarius Oct 27 '12 at 22:45
  • $\begingroup$ Oh hang on, I've noticed a problem. I want the graphs to have different titles and labels but each graph has both of them cl.ly/image/3l172q2B1E1l $\endgroup$ – Theo Oct 27 '12 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.