0
$\begingroup$

I have the following plot

Needs["ErrorBarPlots`"]
Show[Plot [{ 
2 10^3 x  (4 4^2 + (y^2 - R^2 ))/(y^2 - R^2 )^3 /. R -> 3} /. 
FindRoot[
y == Subscript[ω, 0]
     Sqrt[1 + 
     57 Subscript[ω, 0]/
       y (1/(Exp[y/x] - 1) + 1/2 - 
        y/(2 Subscript[ω, 0]))] /. {Subscript[ω, 
   0] -> 23}, {y, 1}], {x, 0, 300}, 
PlotStyle -> {Blue}], {ErrorListPlot[{{290, 0.012263719, 
 0.002}, {240, 0.007675481, 0.002}, {220, 0.008038809, 
 0.002}, {200, 0.008608707, 0.002}, {170, 0.010805872, 
 0.002}, {150, 0.008832903, 0.002}, {130, 0.009263129, 
 0.002}, {120, 0.011290667, 0.002}, {100, 0.014344114, 
 0.002}, {40, 0.025720622, 0.002}, {30, 0.028876792, 0.002}, {20, 
 0.035088327, 0.002}, {15, 0.042578946, 0.002}, {4.2, 
 0.033039767, 0.002}}]}]

And the output is:

errorbar

How can I change the color of points and also error bars?

$\endgroup$
  • $\begingroup$ add the option PlotStyle -> Red to ErrorListPlot? $\endgroup$ – kglr Jul 30 '18 at 20:57
  • $\begingroup$ @kglr already did that but it doesn't work $\endgroup$ – Kassik Jul 30 '18 at 21:02
  • $\begingroup$ Kassik, it works both in v9 (windows10) and v11.3 (Wolfram Cloud). You can also try post-processing ErrorListPlot output using ErrorListPlot[....] /. /. lp : (_Line | _Point) :> {Red, lp}. (This also works both in v9 and in v11.3) $\endgroup$ – kglr Jul 30 '18 at 21:28
1
$\begingroup$
Needs["ErrorBarPlots`"];
With[
 {
  data = {
    {290, 0.012263719, 0.002}, {240, 0.007675481, 0.002},
    {220, 0.008038809, 0.002}, {200, 0.008608707, 0.002},
    {170, 0.010805872, 0.002}, {150, 0.008832903, 0.002},
    {130, 0.009263129, 0.002}, {120, 0.011290667, 0.002},
    {100, 0.014344114, 0.002}, {40, 0.025720622, 0.002},
    {30, 0.028876792, 0.002}, {20, 0.035088327, 0.002},
    {15, 0.042578946, 0.002}, {4.2, 0.033039767, 0.002}
    }
  },
 Show[
  Plot[
   {2 10^3 x (4 4^2 + (y^2 - R^2))/(y^2 - R^2)^3 /. R -> 3}
    /. FindRoot[
     y == ωo Sqrt[
         1 + 57 ωo/
            y (1/(Exp[y/x] - 1) + 1/2 - 
             y/(2 ωo))] /. {ωo -> 23}
     , {y, 1}
     ]
   , {x, 0, 300}
   , PlotStyle -> {Blue}
   , PlotTheme -> "Scientific"
   ],
  ErrorListPlot[
   data
   , PlotStyle -> Red
   , PlotMarkers -> None
   ],
  ListPlot[
   data[[All, {1, 2}]]
   , PlotStyle -> Black]
  ]
 ]

Mathematica graphics

Side note: I suggest you avoid using Subscript.

$\endgroup$
1
$\begingroup$

You can make your own Error plot. See this. Play with dist = 0.8; thickness = 0.003

    data = {{290, 0.012263719, 0.002}, {240, 0.007675481, 0.002}, {220, 
        0.008038809, 0.002}, {200, 0.008608707, 0.002}, {170, 0.010805872,
         0.002}, {150, 0.008832903, 0.002}, {130, 0.009263129, 
        0.002}, {120, 0.011290667, 0.002}, {100, 0.014344114, 0.002}, {40,
         0.025720622, 0.002}, {30, 0.028876792, 0.002}, {20, 0.035088327, 
        0.002}, {15, 0.042578946, 0.002}, {4.2, 0.033039767, 0.002}};

    p1 = Plot[ {2 10^3 x (4 4^2 + (y^2 - R^2))/(y^2 - R^2)^3 /. R -> 3}
    /. FindRoot[
     y == ωo Sqrt[
         1 + 57 ωo/
            y (1/(Exp[y/x] - 1) + 1/2 - 
             y/(2 ωo))] /. {ωo -> 23}
     , {y, 1}
     ]
   , {x, 0, 300}, PlotStyle -> Blue, 
       Frame -> True];
    p2 = ListPlot[data[[All, {1, 2}]], PlotStyle -> Red,
      ];
    dist = 0.8; thickness = 0.003;
    p3 = Graphics[{{Green, Thickness[thickness], 
           Line[{{#[[1]], #[[2]] - #[[3]]}, {#[[1]], #[[2]] + #[[3]]}}], 
           Line[{{#[[1]] - dist, #[[2]] - #[[3]]}, {#[[1]] + 
               dist, #[[2]] - #[[3]]}}], 
           Line[{{#[[1]] - dist, #[[2]] + #[[3]]}, {#[[1]] + 
               dist, #[[2]] + #[[3]]}}]} & /@ data}];

    Show[{p1, p3, p2}, PlotRange -> All]

enter image description here

$\endgroup$
1
$\begingroup$

You can use the sub-option "LineColor" in PlotStyle to have the error lines and the plot markers have different colors:

plot = Plot[{2 10^3 x (4 4^2 + (y^2 - R^2))/(y^2 - R^2)^3 /.  R -> 3} /. 
    FindRoot[y == Subscript[ω, 0] Sqrt[1 + 57 Subscript[ω, 0]/ y (1/(Exp[y/x] - 1) + 
      1/2 - y/(2 Subscript[ω, 0]))] /. {Subscript[ω, 0] -> 23}, 
  {y, 1}], {x, 0, 300}, PlotStyle -> {Blue}];

Show[plot, ErrorListPlot[data, 
    PlotStyle -> Directive[Thick, PointSize[Large], Red, "LineColor" -> Green]]] 

enter image description here

$\endgroup$

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.