'Zig zag' on axes which do not start at zero?

2,556 views
Skip to first unread message

Tom Hebbron

unread,
Aug 10, 2010, 10:12:01 AM8/10/10
to ggplot2
Hi,

I have been trying to figure out how to add a zig-zag or tear to an
axis, to indicate the removed section between the axis and the data
shown on a plot where the y (for instance) axis labels don't start
from zero. See http://www.rss.org.uk/pdf/Graphs%20and%20diagrams.pdf
advising that this is good practice.

Is this currently possible, or horribly convoluted to achieve?

Thanks,

Tom Hebbron

Hadley Wickham

unread,
Aug 10, 2010, 12:59:23 PM8/10/10
to Tom Hebbron, ggplot2
Hi Tom,

It would very convoluted to achieve, and I don't agree that it's good
graphing practice. There is no apriori expectation that all scales
should include zero.

Hadley

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

Ben Bolker

unread,
Aug 10, 2010, 1:17:01 PM8/10/10
to Hadley Wickham, Tom Hebbron, ggplot2
On 10-08-10 12:59 PM, Hadley Wickham wrote:
> Hi Tom,
>
> It would very convoluted to achieve, and I don't agree that it's good
> graphing practice. There is no apriori expectation that all scales
> should include zero.
>
> Hadley
>
> On Tue, Aug 10, 2010 at 9:12 AM, Tom Hebbron<tomhe...@zepler.net> wrote:
>
>> Hi,
>>
>> I have been trying to figure out how to add a zig-zag or tear to an
>> axis, to indicate the removed section between the axis and the data
>> shown on a plot where the y (for instance) axis labels don't start
>> from zero. See http://www.rss.org.uk/pdf/Graphs%20and%20diagrams.pdf
>> advising that this is good practice.
>>
>> Is this currently possible, or horribly convoluted to achieve?
>>
>> Thanks,
>>
>> Tom Hebbron
>>

I am a bit surprised how confidently the document you refer to
asserts that axes must always contain zero. I would say it's one of the
things to consider when designing a graph (all other things being equal
it's better to include zero than not to), but certainly not a fixed
rule. If you do want to do this, and you're willing to work with base
graphics, see axis.break() and gap.plot() in the plotrix package.

Brandon Hurr

unread,
Aug 10, 2010, 3:14:03 PM8/10/10
to Ben Bolker, Hadley Wickham, Tom Hebbron, ggplot2
I can understand why they feel plots without 0 can be misleading. Having a 0 gives an easy frame of reference and having a break accentuates the fact that the plot doesn't start at 0. 

I take it that ggplot doesn't allow for axis breaks of any kind? 

It's not a common requirement for me, but in the past I've taken lots of data points within the first 24 hours and then take measurement a measurement or two at a much later time point. In this case, the early data points get squeezed into oblivion. 

Hadley/others, What are your recommendations for plots such as these and how do you do it within ggplot (is there an example somewhere)?  I'm thinking plot within a plot, but for publication purposes a break would allow for more data in a smaller space.

Thanks,

Brandon


--

Ben Bolker

unread,
Aug 10, 2010, 3:22:58 PM8/10/10
to Brandon Hurr, ggplot2
  I think in the past I've seen a recommendation on the list to facet on a factor that distinguishes x=0 from x>0 with scales="free_x",space="free" .  This does take up a little bit more room than an axis break, and it may not work well if you're already trying to facet on more than one level ...  In some cases where there are a small number of times at which the data are taken people have also recommended making the x variable categorical.
   In a perfect world software would be able to do anything we wanted, easily, and we would all use good judgment in deciding what to tell it to do. In the meantime the people who write the software tend to give lower priority to implementing features they don't think are a very good idea ...

   cheers
     Ben

Hadley Wickham

unread,
Aug 10, 2010, 3:34:55 PM8/10/10
to Ben Bolker, Brandon Hurr, ggplot2
>    In a perfect world software would be able to do anything we wanted,
> easily, and we would all use good judgment in deciding what to tell it to
> do. In the meantime the people who write the software tend to give lower
> priority to implementing features they don't think are a very good idea ...

Yes, especially when our jobs are to do research not (as much as we
love doing it) software development.

Next summer I would like to explore options on finding funding for
some "ggplot2 apprentices" who would spend some time with me learning
the ins and outs of ggplot2, and would then (hopefully!) gain the
ability to contribute pieces that I don't have time for.

Hadley

Tom Hebbron

unread,
Aug 11, 2010, 6:40:23 AM8/11/10
to ggplot2

Google's "summer of code" programme might be worth considering. Submission of proposals is usually March time.

http://code.google.com/soc/

Hadley Wickham

unread,
Aug 11, 2010, 9:36:16 AM8/11/10
to Tom Hebbron, ggplot2
On Wed, Aug 11, 2010 at 5:40 AM, Tom Hebbron <tomhe...@zepler.net> wrote:
>
> Google's "summer of code" programme might be worth considering. Submission
> of proposals is usually March time.
>
> http://code.google.com/soc/

Finding the right student is the challenge - and ideally it would be
more than one so that they could help each other out. They'd need to
know quite a bit of R already, and have some other programming skills.
For it to work, I think they'd also need to come to Rice, so I could
help on one. Getting the money is probably the easy part.

Hadley

PS. I've already had to GSoC students - last year Bjorn Maeland
created crantastic.org, and this year Ian Fellows is working on a gui
for ggplot2

Reply all
Reply to author
Forward
0 new messages