2
$\begingroup$

I have the following data:

datacon0 = {936.1, 1203.4, 1397};
datacon3 = {733.7, 1076.9, 1202.3};
datacon6 = {788.7, 1170.4, 1298};
datacon9 = {761.2, 1142.9, 1273.8};
datacon15 = {1302.4, 1195.7, 869};
datacon18 = {1342, 1183.6, 961.4};
datacon21 = {1369.5, 1232, 1025.2};
datacon24 = {1310.1, 1192.4, 1015.3};

and the following plot:

ListLinePlot[{{0, Around[Mean[datacon0], StandardDeviation[datacon0]]}, {3, Around[Mean[datacon3], StandardDeviation[datacon3]]}, {6, Around[Mean[datacon6], StandardDeviation[datacon6]]}, {9, Around[Mean[datacon9], StandardDeviation[datacon9]]}, {15, Around[Mean[datacon15], StandardDeviation[datacon15]]}, {18, Around[Mean[datacon18], StandardDeviation[datacon18]]}, {21, Around[Mean[datacon21], StandardDeviation[datacon21]]}, {24, Around[Mean[datacon24], StandardDeviation[datacon24]]}}, Ticks -> {{0, 3, 6, 9, 15, 18, 21, 24}, Automatic}, AxesLabel -> {"Time (h)", "cm"}, AxesLabel -> {0, 0}, AxesStyle -> Arrowheads[{{0.045}}], ImagePadding -> 80, ImageSize -> Large, BaseStyle -> {FontFamily -> "Latin Modern Math"}, LabelStyle -> {15, GrayLevel[0]}, PlotRange -> All]

enter image description here

This plot has several problems and I appreciate any help:

  1. I need the plot to start from (0,0) and these zeros to be shown with out extra lines on the left and bottom.

  2. On the x-axis, strangely enough, number 24 is not shown.

  3. The first bar has gone through the arrow head, and I need to push the arrow head a little further.

Thanks for your attention.

$\endgroup$

2 Answers 2

2
$\begingroup$
xvals = {0, 3, 9, 15, 18, 21, 24};

datacons = Symbol["datacon" <> ToString @ #] & /@ xvals;

toAround = MapApply[Around] @* Map[Through @* {Mean, StandardDeviation}];

data = Transpose@{xvals, toAround @ datacons};


ListLinePlot[data,
 PlotRangeClipping -> False, 
 PlotRangePadding -> {{0, Scaled[.1]}, {0, Scaled[.1]}},
 BaseStyle -> AbsoluteThickness[3],
 Mesh -> All,
 MeshStyle -> AbsolutePointSize[15],
 AxesOrigin -> {0, 0},
 Ticks -> {xvals, Automatic},
 AxesLabel -> {"Time (h)", "cm"},
 AxesStyle -> Arrowheads[Medium],
 LabelStyle -> {FontFamily -> "Latin Modern Math", 15, GrayLevel[0]},
 ImageSize -> Large]

enter image description here

$\endgroup$
6
  • $\begingroup$ @Shakeri, please see the update. $\endgroup$
    – kglr
    Commented Jun 19, 2023 at 11:51
  • $\begingroup$ Try replacing "cm" with cm^2 ( or with ToString[cm^2, StandardForm]). $\endgroup$
    – kglr
    Commented Jun 19, 2023 at 11:56
  • $\begingroup$ use "Number of microbes (\[CapitalOmega] \[Times] " <> ToString[cm^2, StandardForm] <> ")" or "Number of microbes\n (\[CapitalOmega] \[Times] " <> ToString[cm^2, StandardForm] <> ")" $\endgroup$
    – kglr
    Commented Jun 19, 2023 at 12:09
  • $\begingroup$ You can also use Row[{"Number of microbes (\[CapitalOmega] \[Times] ", cm^2, ")"}] $\endgroup$
    – kglr
    Commented Jun 19, 2023 at 12:11
  • $\begingroup$ @Shakeri, my pleasure. Welcome to mma.se. $\endgroup$
    – kglr
    Commented Jun 19, 2023 at 12:55
2
$\begingroup$

Something like:

ListLinePlot[{{0, 
   Around[Mean[datacon0], StandardDeviation[datacon0]]}, {3, 
   Around[Mean[datacon3], StandardDeviation[datacon3]]}, {6, 
   Around[Mean[datacon6], StandardDeviation[datacon6]]}, {9, 
   Around[Mean[datacon9], StandardDeviation[datacon9]]}, {15, 
   Around[Mean[datacon15], StandardDeviation[datacon15]]}, {18, 
   Around[Mean[datacon18], StandardDeviation[datacon18]]}, {21, 
   Around[Mean[datacon21], StandardDeviation[datacon21]]}, {24, 
   Around[Mean[datacon24], StandardDeviation[datacon24]]}}, 
 Ticks -> {{0, 3, 6, 9, 15, 18, 21, 24}, Automatic}, 
 AxesLabel -> {"Time (h)", "cm"}, AxesStyle -> Arrowheads[{{0.045}}], 
 ImagePadding -> 80, ImageSize -> Large, 
 BaseStyle -> {FontFamily -> "Latin Modern Math"}, 
 LabelStyle -> {15, GrayLevel[0]}, 
 PlotRange -> {{-0, 28}, {700, 1500}}]

enter image description here

Addendum

To answer your questions:

ListLinePlot[{{0, 
   Around[Mean[datacon0], StandardDeviation[datacon0]]}, {3, 
   Around[Mean[datacon3], StandardDeviation[datacon3]]}, {6, 
   Around[Mean[datacon6], StandardDeviation[datacon6]]}, {9, 
   Around[Mean[datacon9], StandardDeviation[datacon9]]}, {15, 
   Around[Mean[datacon15], StandardDeviation[datacon15]]}, {18, 
   Around[Mean[datacon18], StandardDeviation[datacon18]]}, {21, 
   Around[Mean[datacon21], StandardDeviation[datacon21]]}, {24, 
   Around[Mean[datacon24], StandardDeviation[datacon24]]}}, 
 PlotStyle -> Thick, 
 Ticks -> {{0, 3, 6, 9, 15, 18, 21, 24}, Automatic}, 
 AxesLabel -> {"Time (h)", "cm"}, AxesStyle -> Arrowheads[{{0.045}}], 
 ImagePadding -> 80, ImageSize -> Large, 
 BaseStyle -> {FontFamily -> "Latin Modern Math"}, 
 LabelStyle -> {15, GrayLevel[0]}, 
 PlotRange -> {{-0, 28}, {700, 1500}}, 
 Epilog -> {PointSize[0.02], 
   Point[{{0, Mean[datacon0]}, {3, Mean[datacon3]}, {6, 
      Mean[datacon6]}, {9, Mean[datacon9]}, {15, 
      Mean[datacon15]}, {18, Mean[datacon18]}, {21, 
      Mean[datacon21]}, {24, Mean[datacon24]}}], Darker[Blue], 
   Thickness[0.005], 
   Line[{{0.1, Mean[datacon0] - StandardDeviation[datacon0]}, {0, 
      Mean[datacon0] + StandardDeviation[datacon0]}}]}]

enter image description here

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.