Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
    
Thanks, I tried this but it threw up a lot of errors cl.ly/image/2L2C2t1l300k –  Theo Windebank Oct 27 '12 at 22:27
    
@TheoWindebank Works Ok. here. Perhaps a version problem. Before going deeper, shut down mathematica and run it in a fresh session. –  belisarius Oct 27 '12 at 22:33
    
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? –  Theo Windebank Oct 27 '12 at 22:38
    
@TheoWindebank Typically, some previous definition of data –  belisarius Oct 27 '12 at 22:45
    
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 –  Theo Windebank Oct 27 '12 at 22:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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