0
$\begingroup$

May I ask how to add the gradient that I have calculated into the errorlistplot?

JoinMean = Join[{MeanC5cm, MeanC7cm, MeanC10cm, MeanC20cm, MeanC27cm, MeanC30cm}]
    {44.0215, 73.6246, 117.757, 307.112, 445.527, 352.733}

JoinStDv = Join[{Sd5, Sd7, Sd10, Sd20, Sd27, Sd30}]
{3.31495, 3.27642, 23.9473, 27.6356, 25.0707, 23.2319}

Graph1 = ErrorListPlot[{{{5, MeanC5cm}, 
    ErrorBar[Sd5]}, {{7, MeanC7cm}, ErrorBar[Sd7]}, {{10, MeanC10cm}, 
    ErrorBar[Sd10]}, {{20, MeanC20cm}, 
    ErrorBar[Sd20]}, {{27, MeanC27cm}, 
    ErrorBar[Sd27]}, {{30, MeanC30cm}, ErrorBar[Sd30]}}, 
  AxesOrigin -> {0, 0}, AxesLabel -> {"Length", "K\[CapitalOmega]"}]

MeanGradient = Fit[JoinMean, {1, x}, x]
-61.3992 + 81.389 x
$\endgroup$
1
$\begingroup$
MeanGradient =  Fit[Transpose[{{5, 7, 10, 20, 27, 30}, JoinMean}], {1, x}, x];

Show[Graph1, Plot[MeanGradient, {x, 0, 30}, PlotStyle -> Directive[Red, Thick]], 
  PlotRange -> All, PlotLabel -> MeanGradient]

enter image description here

Alternatively, you can add the option

Epilog -> Plot[MeanGradient, {x, 0, 30}, PlotStyle -> Directive[Red, Thick]][[1]]

to your ErrorListPlot that produces Graph1.

$\endgroup$
  • $\begingroup$ Thank you i will give it a try. $\endgroup$ – ljsg Jun 27 '18 at 6:06

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.