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 help
-
$\begingroup$ {4978,5148} for 0^+, {4976,5173,5182} for 1^+, {5188} for 2^+ $\endgroup$– physics-physicsJun 16, 2022 at 21:43
1 Answer
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
]
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.
-
$\begingroup$ Thank you very much for your help. How would it possible to place by hand? $\endgroup$ Jun 17, 2022 at 8:19