Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there an easy (recommended) way to align regular plots (e.g. ListPlot or Plot) with chart type graphics (BarChart or DistributionChart)?

For example:

   DistributionChart[Table[RandomReal[NormalDistribution[i, .2], 1000], {i, 1, 10}]], 
   ListPlot[Range[1, 10]]

Not aligned!

I would like the points of the ListPlot to reside exactly on top of the DistributionChart elements. Furthermore, the coordinate positioning of chart elements seems to vary with the number of elements (which is ridiculous).

    DistributionChart[Table[RandomReal[NormalDistribution[i, .2], 1000], {i, 1, 3}]], 
    ListPlot[Range[1, 3]]

Not aligned 2

share|improve this question
Are you sure you aren't doing something different? This is what I get (and a similar correct figure for the second case). Try doing it in a fresh kernel (and without custom options, if any) – R. M. Jul 9 '12 at 19:18
@R.M I get the same as the OP. Version mismatch? – Dr. belisarius Jul 9 '12 at 19:22
I get the same output as @R.M (v Windows Vista 64 bit) – kglr Jul 9 '12 at 19:25
No, fresh kernel doesn't help. I plotted the diagrams with Mathematica on Mac OS X 10.7. Tried it on Windows with the same Mathematica version and get the same result. Which version are you using @R.M ? – phantomas1234 Jul 9 '12 at 19:27
I get the same as R.M with Mathematica 8.0.4 for OS X. – Heike Jul 9 '12 at 19:40
up vote 7 down vote accepted

Seems it is a problem localized to version 8.0.0. Here is a way to fix it by scaling your ListPlot using the FrameTicks of the DistributionChart.

k = DistributionChart[Table[RandomReal[NormalDistribution[i, .2], 100], {i, 1, 20}], 
         Method -> {"BoxWidth" -> "Fixed"}]; 
l = (Sort@((FrameTicks /. Options[k, "FrameTicks"])[[2, 1, All, 1]]))[[2 ;; -2]];
f = Interpolation[Transpose[{Range@Length@l, l}]];
Show[k, ListPlot[Table[{f@i, i}, {i, 15}], PlotStyle -> Directive[Red, PointSize[Large]]]]

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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