Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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"]

enter image description here

share|improve this question
add comment

1 Answer 1

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 /@ Charting`FindTicks[{1, 0}, {1, 0}][##] &, Automatic},
   {Charting`FindTicks[{1, 0}, {1, 0}][##] &, Automatic}}
 ]

Mathematica graphics

share|improve this answer
    
Thank you Michael. That works great for me. –  Balaji Oct 16 '13 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. –  Sjoerd C. de Vries Oct 16 '13 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? –  Michael E2 Oct 17 '13 at 6:47
add comment

Your Answer

 
discard

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.