# Custom plot markers in DistributionChart

I would like to use the ChartElementFunction option of DistributionChart to plot data with a custom style that includes custom plot markers, such as open circles. I am struggling with the scaling of the markers, though.

If I use Points as plot markers, everything is fine:

data = Table[RandomReal[i + {1, 3}, 10], {i, 5}];

{Black, PointSize[Large], Point[{RandomReal[{xmin, xmax}], #}]& /@ data};

DistributionChart[data, ChartElementFunction -> cef1]


If I use Circles, they are affected by the aspect ratio of the plot and shown as ellipses:

cef2[{{xmin_, xmax_}, {ymin_, ymax_}}, data_, metadata_] :=
{Black, Circle[{RandomReal[{xmin, xmax}], #}, 0.05]& /@ data};

DistributionChart[data, ChartElementFunction -> cef2]


Is there a way to get the scaling right, for example make the markers behave like PlotMarkers in ListPlot?

Use Offset to set the radius in printer points:

cef2[{{xmin_, xmax_}, {ymin_, ymax_}}, data_, metadata_] := {Black,
Circle[{RandomReal[{xmin, xmax}], #}, Offset[3]] & /@ data};

DistributionChart[data, ChartElementFunction -> cef2]


You can make the radius an argument of the chart element function:

cef2b[radius_: 3][{{xmin_, xmax_}, {ymin_, ymax_}}, data_, metadata_] := {Black,
Circle[{RandomReal[{xmin, xmax}], #}, Offset[radius]] & /@ data};

DistributionChart[data, ChartElementFunction -> cef2b[]]


same picture

Alternatively, you can use Inset[Graphics[Circle[]],...] to make the glyph:

cef2c[size_: .025][{{xmin_, xmax_}, {ymin_, ymax_}}, data_, metadata_] := {Black,
Inset[Graphics @ Circle[], {RandomReal[{xmin, xmax}], #}, Automatic,
Scaled[size]] & /@ data};

DistributionChart[data, ChartElementFunction -> cef2c[.05], AspectRatio -> 1/2]


Use ChartElementFunction -> cef2c[.1] to get

• Thanks so much! Exactly what I was looking for. Jun 21, 2019 at 6:54
• @wigg0t, my pleasure. Thank you for the accept.
– kglr
Jun 21, 2019 at 6:55