# How to frame a PairedHistogram and manipulate the frame ticks?

How can I Frame a PairedHistogram and manipulate the frame ticks? I want to specify and control the frame ticks in the paired histogram below.

spacez = RandomVariate[PoissonDistribution[11], 1000];
spacem = RandomVariate[PoissonDistribution[11], 1000];
PairedHistogram[spacez, spacem, {1, 11, 1}, PlotRange -> {{All, All}},
ChartStyle -> {{Red, Blue}}, BaseStyle -> {FontSize -> 24},
AxesStyle -> Thick, BarSpacing -> 0,
ColorFunction -> Function[Opacity[0.5]], BarOrigin -> "XAxis"]


One problem is that PairedHistogram constructs its own axes/ticks, overriding to some extent (and thereby interfereing with) the standard system approach. I don't know why it does this. Ticks seems to be able to be used to relabel the automatically generated ticks (an observation), but the option cannot be used as it can with, say, Plot. Passing a function, for instance, has no effect.

However, one can use Frame. Use the Axes options Frame on. Then you can use FrameTicks to specify ticks. I made a function absSingleTick to reverse the sign of ticks with negative coordinates.

SeedRandom[1];
spacez = RandomVariate[PoissonDistribution[11], 1000];
spacem = RandomVariate[PoissonDistribution[11], 1000];

absSingleTick[{a_, b_}] := {a, Abs[b]};
absSingleTick[t_] := t;

PairedHistogram[spacez, spacem, {1, 11, 1}, PlotRange -> {{All, All}},
ChartStyle -> {{Red, Blue}}, BaseStyle -> {FontSize -> 24},
BarSpacing -> 0, ColorFunction -> Function[Opacity[0.5]],
BarOrigin -> "XAxis",
Axes -> False, Frame -> True, FrameStyle -> Purple,
FrameTicks -> {
{absSingleTick /@ ChartingFindTicks[{1, 0}, {1, 0}][##] &, Automatic},
{ChartingFindTicks[{1, 0}, {1, 0}][##] &, Automatic}}
]


• Thank you Michael. That works great for me. Oct 16, 2013 at 18:37
• Would that work for the first example of the PairedHistogram page? Can't try it right now, but I guess the split x-axis will cause problems. Oct 16, 2013 at 21:39
• @SjoerdC.deVries You can remove the gap with BarSpacing -> 0 as the OP does. However, I'm finding that (any) ticks functions for the horizontal frame element generate error messages, when I try the above method on the first PairedHistogram example. :( Bug? Oct 17, 2013 at 6:47