Combining and aligning "chart" type graphics with regular plots - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-09-21T14:29:43Z https://mathematica.stackexchange.com/feeds/question/8100 https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/8100 8 Combining and aligning "chart" type graphics with regular plots phantomas1234 https://mathematica.stackexchange.com/users/338 2012-07-09T19:16:37Z 2012-07-09T20:19:55Z <p>Is there an easy (recommended) way to align regular plots (e.g. <code>ListPlot</code> or <code>Plot</code>) with chart type graphics (<code>BarChart</code> or <code>DistributionChart</code>)?</p> <p>For example:</p> <pre><code>Show[ DistributionChart[Table[RandomReal[NormalDistribution[i, .2], 1000], {i, 1, 10}]], ListPlot[Range[1, 10]] ] </code></pre> <p><img src="https://i.stack.imgur.com/KSVDe.jpg" alt="Not aligned!"></p> <p>I would like the points of the <code>ListPlot</code> to reside exactly on top of the <code>DistributionChart</code> elements. Furthermore, the coordinate positioning of chart elements seems to vary with the number of elements (which is ridiculous).</p> <pre><code>Show[ DistributionChart[Table[RandomReal[NormalDistribution[i, .2], 1000], {i, 1, 3}]], ListPlot[Range[1, 3]] ] </code></pre> <p><img src="https://i.stack.imgur.com/M0MV8.jpg" alt="Not aligned 2"></p> https://mathematica.stackexchange.com/questions/8100/-/8102#8102 7 Answer by Dr. belisarius for Combining and aligning "chart" type graphics with regular plots Dr. belisarius https://mathematica.stackexchange.com/users/193 2012-07-09T20:01:26Z 2012-07-09T20:19:55Z <p>Seems it is a problem localized to version 8.0.0. Here is a way to fix it by scaling your <code>ListPlot</code> using the <code>FrameTicks</code> of the <code>DistributionChart</code>.</p> <pre><code>k = DistributionChart[Table[RandomReal[NormalDistribution[i, .2], 100], {i, 1, 20}], Method -&gt; {"BoxWidth" -&gt; "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 -&gt; Directive[Red, PointSize[Large]]]] </code></pre> <p><img src="https://i.stack.imgur.com/KHSBu.png" alt="enter image description here"></p>