1
$\begingroup$

0

I am creating some Listplots of some data with the following bit of code:

bbbarexpmasses = {{1, 9.4449}, {2, 9.8999}, {3, 10.023}, {4, 
   10.163}, {5, 10.260}, {6, 10.355}, {7, 10.579}}

bbbartheorymasses = {{1, 9.4258128}, {2, 9.884308}, {3, 
   9.9751791}, {4, 10.145617}, {5, 10.270137}, {6, 10.197768}, {7, 
   10.430176}}

BBbarcomparison = 
 ListPlot[{bbbarexpmasses, bbbartheorymasses}, 
  PlotMarkers -> {Automatic, Medium}, ImageSize -> Large, 
  Frame -> All, 
  Ticks -> {{{1, "1S"}, {2, "1P"}, {3, "2S"}, {4, "1D"}, {5, 
      "2P"}, {6, "3S"}, {7, "4S"}}, {9.4449, 9.8999, 10.023, 10.163, 
     10.260, 10.355, 10.579}}]

which works fine and produces the following plot:BBbar

But now I would like to have the PlotMarkers to be wider, more like the markers in this plot. masses

Is there an option in Mathematica to do something like this? Thanks.

$\endgroup$
1
  • 1
    $\begingroup$ That plot looks more like a BarChart in my opinion, that should make this type of plot easier. You can then use ChartElementFunction to draw the lines $\endgroup$
    – Lukas Lang
    Jun 24, 2021 at 8:04

1 Answer 1

1
$\begingroup$

Use PlotMarkers to specify your shape, add Scaled[] with each shape to have the right size, and use PlotStyle to specify the color of each series. Because of the large shapes, the PlotRange should be specified manually.

Table used to generate PlotMarkers shapes, each with some variation.

ListPlot[{bbbarexpmasses, bbbartheorymasses}, ImageSize -> Large, 
 Frame -> All, 
 Ticks -> {{{1, "1S"}, {2, "1P"}, {3, "2S"}, {4, "1D"}, {5, "2P"}, {6,
      "3S"}, {7, "4S"}}, {9.4449, 9.8999, 10.023, 10.163, 10.260, 
    10.355, 10.579}}, 
 PlotMarkers -> 
  Table[{Graphics[Rectangle[{0, 0}, {10, i}, RoundingRadius -> .7]], 
    Scaled[.02*i + .1]}, {i, {1, 1.2}}], 
 PlotStyle -> {GrayLevel[.3], GrayLevel[.7]}, 
 PlotRange -> {{.5, 7.5}, Automatic}]

Result:

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you, this is very useful! $\endgroup$
    – Christian
    Jun 24, 2021 at 10:35

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.