# Aligning object in Graphic

When I try putting dot graph(ListPlot) named dg as below to my Histogram graphic.The horizental axis is not exactly aligned. How to fix my code?

dg = ListPlot[{Transpose[{{0.66, -0.09}, ConstantArray[0.1, i]}]},
PlotStyle -> Red, PlotRange -> {{-6, 6}, {0, 5}},
PlotRangePadding -> {{0, 0}, {0, 0}}]


(*How to fix code?*)
Histogram[{0.66, -0.09}, PlotRange -> {{-6, 6}, Automatic},
Epilog -> {Inset[dg, Scaled@{0, 0}, Scaled@{0, 0}, Scaled[1]]},
PlotRangePadding -> {{0, 0}, {0, 0}}]


• Use Show to combine the two plots, rather than an Inset. Show[{Histogram[...], dg}] after removing the Epilog from Histrogram. Commented Nov 15, 2023 at 15:56

### 1. Using Epilog + Inset

1. Use the same ImagePadding (say ImagePadding -> 20) in ListPlot and Histogram.
2. Use ImageScaled to specify size (the fourth argument) in Inset[...].
dg = ListPlot[{Transpose[{{0.66, -0.09}, ConstantArray[0.1, 2]}]},
PlotStyle -> Red,
PlotRange -> {{-6, 6}, {0, 5}},

Histogram[{0.66, -0.09},
PlotRange -> {{-6, 6}, Automatic},
Epilog -> {Inset[dg, {0, 0}, {0, 0}, ImageScaled[1]]},


In this case, Inset[dg, Scaled@{0, 0}, Scaled@{0, 0}, ImageScaled[1]] gives the same result.

Add the option AxesOrigin -> {3,0} in Histogram[...] to show two vertical axes:

See:

### 2. Epilog only

An easier approach is to avoid the alignment issue using graphics primitives from dg (that, is dg[[1]]) as the option value for Epilog and, if needed, modify the vertical tick labels using ChartingFindTicks.

Histogram[{0.66, -0.09},
PlotRange -> {{-6, 6}, Automatic},
Epilog -> {dg[[1]]},

Combine dg and histogram using Show as suggested by MarcoB in comments; and, if needed, modify the vertical tick labels:
Show[Histogram[{0.66, -0.09}, PlotRange -> {{-6, 6}, Automatic},
Ticks -> {Automatic, ChartingFindTicks[{0, 1}, {0, 5}]},
`