3
$\begingroup$

I have two questions about adapting a PairedBarChart to my needs.

1.I have a PairedBarChart with many bars like this

   size = 50;
        PairedBarChart[RandomReal[1, size], RandomReal[1, size], 
         AspectRatio -> 1]

I changed the AspectRatio (e.g. 3 in this case but could be higher)

size = 50;
PairedBarChart[RandomReal[1, size], RandomReal[1, size], 
 AspectRatio -> 3]

Now there is a space at the bottom between the axis and the last bar which gets larger the higher the Aspect Ratio.

How can I remove that space at the bottom or make it a specific length respectively?

2.I want to add another axis on the top of the Chart with ticks of my choice, i.e. not from 0 to 1 but another scale e.g. 0 to 100. Is it possible to do so?

$\endgroup$
  • $\begingroup$ Your first question can be solved with the following: PairedBarChart[RandomReal[1, size], RandomReal[1, size], PlotRange -> {Automatic, {0, size}}, ImagePadding -> {{0, 0}, {20, 0}}]. To see that ImagePadding is necessary, try it without it. $\endgroup$ – JimB Apr 4 '17 at 14:25
4
$\begingroup$

Here is code that answers both of the questions:

size = 50;
PairedBarChart[RandomReal[1, size], RandomReal[1, size], 
 AspectRatio -> 2, AxesOrigin -> {0, 1}, Frame -> True, 
 FrameTicks -> {{None, 
    None}, {{#, 100 #} & /@ Range[0, 1, 0.25], {#, 100 #} & /@ 
     Range[0, 1, 0.25]}}]

enter image description here

Answering a comment by @user6014 :

I took his post to mean he wanted the original ticks on the bottom, but an alternative one on top. Yours merely replaces both the top and the bottom. Is what I interpreted possible, i.e. 2 different ticks sets? (perhaps I misinterpreted the poster, though...)

size = 50;
PairedBarChart[RandomReal[1, size], RandomReal[1, size], 
 AspectRatio -> 2, AxesOrigin -> {0, 1}, Frame -> True, 
 FrameTicks -> {{None, 
    None}, {Range[0, 1, 0.25], {#, 100 #} & /@ Range[0, 1, 0.25]}}]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ I took his post to mean he wanted the original ticks on the bottom, but an alternative one on top. Yours merely replaces both the top and the bottom. Is what I interpreted possible, i.e. 2 different ticks sets? (perhaps I misinterpreted the poster, though...) $\endgroup$ – user6014 Apr 4 '17 at 14:30
  • $\begingroup$ @user6014 I think you are probably right, and that is easily done with the option value of FrameTicks. I updated my answer. $\endgroup$ – Anton Antonov Apr 4 '17 at 14:31
  • $\begingroup$ @AntonAntonov: Thanks very much! I wanted to display two different ticks which you already answered as well, great :) $\endgroup$ – holistic Apr 4 '17 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.