I need to make several plots displaying a ListPlot
overlaid with a Histogram
and close to it (ideally even sharing X axis) a Plot. After reading answers to similar questions, I've got his far:
randomData2 = Table[{RandomVariate[dist], RandomReal[]}, {i, 1, 3000}];
opts = {AspectRatio -> 1, PlotRangePadding -> 0, ImagePadding -> 50};
plot1 = ListPlot[ randomData2,
PlotMarkers -> {".", 10}, Frame -> {True,True,True, True},
FrameTicks -> {{None, All}, {True, None}}, opts ];
plot2 = Histogram[ randomData2[[All, 1]], 50, "ProbabilityDensity",
ChartStyle -> Red, ChartBaseStyle -> Directive[Opacity[0.5]],
FrameStyle -> {Automatic, Automatic, Automatic, Red}, opts];
plot3 = Plot[PDF[dist, x], {x, 0, 5},
PlotStyle -> PointSize[Medium], AspectRatio -> 1,
PlotRangePadding -> 0, ImagePadding -> 50, Frame -> True];
plot4 = Overlay[{plot1, plot2}, ImageSize -> Full]
GraphicsGrid[{{plot3}, {plot4}}]
My questions:
- The
Overlay
seems to be a little "moved". Numbers and ticks in the X Axis are not exactly on top of the previous. I could hide one, but I guess that the plots are not exactly aligned. How to align them exactly and automatically? - How to make the plots in the
GraphicsGrid
of the same size, scale and aligned so that one can easily compare the results in the upper and lower graphic?
I cannot manually align them with padding as I have to use the same structure with many different graphics of different sizes and ranges.