Patch: fix empty colorbar guide

53 views
Skip to first unread message

QRD

unread,
Sep 16, 2013, 6:44:15 AM9/16/13
to ggp...@googlegroups.com
Hi,

A colleague recently came across an R crash, which I can boil down to
the following, running under Rgui on Windows 7:

library(ggplot2)
ggplot(data.frame(x=1, y=1, z=4.7), aes(x, y, z=z)) + stat_summary2d()

This reliably causes a segmentation fault. I have sent a separate email
to the R-devel list about the segfault itself, but I think the situation
could be improved on the ggplot side too. The relevant code is in
guide_train.colorbar():

.bar <- discard(pretty(scale_limits(scale), n = guide$nbin), scale_limits(scale))

When there's only one value, the two values returned from scale_limits()
are the same, and if that value doesn't happen to be included in the
list returned from pretty(), all the tick-mark locations get discarded.
Then .bar is empty and R crashes when trying to draw an empty raster.

The attach patch tries to do something sensible in this case, although
I haven't convinced myself it'll work in all situations. Could somebody
who knows this code better have a look please?

Thanks very much,

Ben.

avoid-empty-colorbar-guide.patch
Reply all
Reply to author
Forward
0 new messages