1
$\begingroup$

How can I obtain the following plot via Mathematica? I have my own data but I couldn't have obtained the plot. Thank you for your helpMass spectrum

$\endgroup$
1
  • $\begingroup$ {4978,5148} for 0^+, {4976,5173,5182} for 1^+, {5188} for 2^+ $\endgroup$ Jun 16, 2022 at 21:43

1 Answer 1

4
$\begingroup$

Here's an attempt made by forcing BarChart into service with a custom ChartElementFunction to generate just a line:

ClearAll[cef]
cef[{{xmin_, xmax_}, {ymin_, ymax_}}, val_, __] := 
 {
   Line[{{xmin, ymax}, {xmax, ymax}}],
   Inset[Style[val, 16], {Mean[{xmin, xmax}], ymax + 15}]
 }

BarChart[
 {Style[{4978, 5148}, Red],
  Style[{4976, 5173, 5182}, Blue], 
  Style[{5188}, Purple]},
 PlotRange -> {Automatic, {4950, 5310}},
 ChartElementFunction -> cef,
 ChartLayout -> "Overlapped",
 ChartLabels -> {{}, 
   MapThread[
    Style[#1, 16, #2] &, {{"\!\(\*SuperscriptBox[\(0\), \(+\)]\)", 
      "\!\(\*SuperscriptBox[\(1\), \(+\)]\)", 
      "\!\(\*SuperscriptBox[\(2\), \(+\)]\)"}, {Red, Blue, 
      Purple}}], {"", "", ""}},
 Frame -> True, Axes -> False,
 FrameTicks -> {{Automatic, None}, {Automatic, None}},
 FrameTicksStyle -> Directive[Black, 16],
 FrameLabel -> {None, Style["Mass (MeV)", 18, Black]},
 AspectRatio -> 1
]

a similar plot to OP, but still trouble with text labels

As you can see, the text labels are not quite right, because intelligent placement would be needed for the central data set. I would recommend actually placing them by hand instead.

$\endgroup$
1
  • $\begingroup$ Thank you very much for your help. How would it possible to place by hand? $\endgroup$ Jun 17, 2022 at 8:19

Your Answer

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

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