3
$\begingroup$

I am using the PairedBarChart feature as follows:

PairedBarChart[Range[5], Range[5], BarOrigin -> "XAxis"]

enter image description here

How can I (i) remove and (ii) change the number of the small tick marks on the y-axis (i.e., the ones between the numbers 1, 2, 3, ...)?

Thanks for your help!

$\endgroup$
3
  • 1
    $\begingroup$ Try: PairedBarChart[Range[5], Range[5], BarOrigin -> "XAxis", Ticks -> {{None}, {None}}] $\endgroup$
    – Boson
    Commented Mar 21, 2014 at 17:33
  • $\begingroup$ Or if you want the whole y-axis gone: PairedBarChart[Range[5], Range[5], BarOrigin -> "XAxis"] /. Deploy[__] :> {}. $\endgroup$
    – Silvia
    Commented Mar 21, 2014 at 17:43
  • $\begingroup$ Thanks for your help. Your comments work for the original question. Actually my problem is a bit different so I changed the question now (I thought the answer to the original question would solve the problem but it didn't). Maybe you have an idea for the new question as well. Thanks! $\endgroup$
    – Posch79
    Commented Mar 21, 2014 at 17:57

2 Answers 2

2
$\begingroup$

Regrettably, I don't believe such an option is intrinsic to PairedBarChart. You can directly manipulate the graphic object to accomplish this, e.g.:

g = PairedBarChart[Range[10], Range[10], BarOrigin -> "XAxis"];
g[[1, 2, 2, 1, 1, 1, 3, 1, 2]] = {};
g[[1, 2, 2, 1, 2, 1, 3, 1, 2]] = {};

enter image description here

If you're going to need this often, probably best to make a simple function that parses content of object and monkey-patches it to remove ticks...

$\endgroup$
3
  • $\begingroup$ Thanks. Is it also possible not to remove the small ticks but to change the number of small ones between the large ones? $\endgroup$
    – Posch79
    Commented Mar 23, 2014 at 17:46
  • $\begingroup$ @Posch79: Sure, using the same kind of method - just poke around at the structure of the graphic object. Other options (not precisely same output) might be one of the custom ticks packages out there in the ether, or using a frame with user-generated frame ticks. We all hope WRI adds more tick-control options in future versions: you can see this kind of question pop up here quite a bit... $\endgroup$
    – ciao
    Commented Mar 23, 2014 at 21:51
  • $\begingroup$ Could you provide a code example how to do that? Thank you so much. $\endgroup$
    – Posch79
    Commented Mar 24, 2014 at 0:10
0
$\begingroup$

It turns out that the Line primitives for major and minor ticks appear next to each other and post-processing to remove the second of these lines using a simple rule gives the desired result:

ClearAll[removeMinorTicks]    
removeMinorTicks = # /. {a___, {l1_Line}, {_Line}, x___} :> {a, {l1}, x} &;

Examples:

pbc1 = PairedBarChart[Range[5], Range[5], BarOrigin -> "XAxis", ImageSize -> 300];
pbc2 = PairedBarChart[{{1, 2}, {1, 2, 3}, {1, 2, 3, 4}}, {{1, 2}, {1, 2, 3}, {1, 2, 3, 4}},
  ImageSize -> 300];

Row[{pbc1, removeMinorTicks @ pbc1}, Spacer[10]]

enter image description here

Row[{pbc2, removeMinorTicks @ pbc2}, Spacer[10]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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