Dear all,
I agree that colours look nicer than different shades of grey and I
also agree that the problem with colour blindness can easily be
avoided by checking for the right colours. However, there are some
good reasons why black and white patterns would be a huge improvement
for ggplot2. Almost a third (ca. 10 out of 33) of the geoms uses an
area that could be filled with a colour or a pattern. To publish a
nice coloured graph in a journal can cost up to several hundred Euros
per graph, which is not really cheap in my view. In some journals
coloured graphs can be published for free electronically but will be
printed in black and white if the authors don’t pay for the coloured
graphs. But even if graphs are published in colour electronically and
in print there still remains the problem that e.g. a librarian might
copy it in black and white at an article request which in the worst
case makes a graph useless. Different shades of grey are a good
alternative but only for a very limited number of colours/shades. The
most robust and basic solution for all these problems would be simple
black and white patterns. Only problem: they should not look stupid or
clumsy like in Excel but I’m sure there are some nice patterns
available. So if anyone could implement black and white patterns into
the next version of ggplot I would be really grateful and happy and I
think the same would apply to many other people as well.
Best wishes,
Martin
On 15 Feb., 10:48, baptiste auguie <
bapt4...@googlemail.com> wrote:
> One approach to make fill patterns with polygons would be to use grobX
> and grobY. I haven't worked out the details for parallel lines at an
> angle, but it seems doable. Other patterns than lines would be more
> problematic, unless we restrict thepatternto strictly inner elements
> (e.g. points), because their intersection with the polygon border
> would be a nightmare.
>
> Here's an example of usage for grobX, feel free to suggest adaptations
> for parallel lines,
>
> library(grid)
>
> g <- polygonGrob(0.1*cos(seq(0,2*pi,length=300)) +0.5,
> 0.2*sin(seq(0,2*pi,length=300))+0.5, def="npc")
>
> gtheta <- function(g, theta){
>
> sapply(theta, function(.t){
> gx <- convertX(grobX(g, .t), "npc")
> gy <- convertY(grobY(g, .t), "npc")
>
> c(gx,gy)
> })
>
> }
>
> angles <- seq(10,360,by=10)
> p <- gtheta(g, angles)
>
> grid.newpage()
> grid.draw(g)
> grid.points(p[1,], p[2,], gp=gpar(cex=0.2),
> default.units="npc")
>
> grid.segments(0.5,0.5, p[1,],p[2,], gp=gpar(cex=0.2),
> default.units="npc")
>
> baptiste
>
> On Thu, Jan 20, 2011 at 9:38 AM, Brandon Hurr <
bhiv...@gmail.com> wrote:
> > I could see it being useful for those dreaded dynamite plots, but also
> > geom_tile. If it could be made to work with geom_polygon & geom_area you
> > could use it topatternover an area of a map. I see its' main purpose as
> > making graph objects distinctive in the absence of color or over the top of
> > color. I would suggest that is perhaps it's sole purpose (primarily for
> > publication reasons), although I'm sure others could come up with other
> > reasons it could be useful to them.
> > B
>
> > On Thu, Jan 20, 2011 at 08:18, baptiste auguie <
bapt4...@googlemail.com>
> > wrote:
>
> >> patternGrob is a grob already. What's really missing is some work to
> >> improve its implementation, and on the ggplot2 side a simple wrapper
> >> together with appropriate scales. The main question I have is, is it
> >> worth the trouble considering that it would be limited to filling
> >> rectangles?
>
> >> baptiste
>
> >> On Wed, Jan 19, 2011 at 6:45 PM, Brandon Hurr <
bhiv...@gmail.com> wrote:
> >> > How close is patternGrob() to being a grid grob?
> >> > Does it need more patterns?
> >> > Brandon
>
> >> > On Wed, Jan 19, 2011 at 14:38, Hadley Wickham <
had...@rice.edu> wrote:
>
> >> >> If anyone wanted to contribute this, the place to start would be
> >> >> writing a grid grob that supported it. Then I could easily write the
> >> >> supporting infrastructure in ggplot2.
>
> >> >> Hadley
>
> >> >> On Wed, Jan 19, 2011 at 5:49 AM, baptiste auguie
> >> >> <
bapt4...@googlemail.com> wrote:
> >> >> > I haven't found the motivation nor the time to give it a shot either.
> >> >> > With the new ggplot2(3?) infrastructure, perhaps this would make a
> >> >> > good exercise to see how it all works now (I don't know if it's
> >> >> > functional yet, though).
>
> >> >> > baptiste
>
> >> >> > On Tue, Jan 18, 2011 at 9:17 PM, Brandon Hurr <
bhiv...@gmail.com>
> >> >> > wrote:
> >> >> >> I looked into it, but my knowledge of the ggplot subsystem quickly
> >> >> >> prevented
> >> >> >> me from understanding what I was doing and I stopped to work on
> >> >> >> other
> >> >> >> things. Sadly, that was as far as I got. I would have/still would
> >> >> >> gladly
> >> >> >> contribute to something if I can help. I'm mostly good at breaking
> >> >> >> things
> >> >> >> though.
> >> >> >> Brandon
>
> >> >> >> On Tue, Jan 18, 2011 at 19:56, Luciano Selzer
> >> >> >> <
luciano.sel...@gmail.com>
> >> >> >> wrote:
>
> >> >> >>> Hello, just to know. Has there been any progress in writing a new
> >> >> >>> geom
> >> >> >>> that can use patterns?
> >> >> >>> Thank you
> >> >> >>> Luciano
>
> >> >> >>> 2010/9/13 baptiste Auguié <
bapt4...@googlemail.com>
>
> >> >> >>>> you'll need a geom, I think, otherwise the output of your scale
> >> >> >>>> won't
> >> >> >>>> be
> >> >> >>>> turned into a graphical object; there is currently no geom that
> >> >> >>>> knows
> >> >> >>>> how to
> >> >> >>>> draw a patternGrob.
> >> >> >>>> baptiste
> >> >> >>>> On Sep 13, 2010, at 4:12 PM, Brandon Hurr wrote:
>
> >> >> >>>> Do you actually need a geom_*? Seems like what you really need is
> >> >> >>>> a
> >> >> >>>> scale_. Like a hacked version of scale_fill_color() that outputs
> >> >> >>>> patterns
> >> >> >>>> instead. Or are scales actually geom()s in hiding?
> >> >> >>>> Brandon
>
> >> >> >>>> On Mon, Sep 13, 2010 at 14:39, baptiste Auguié
> >> >> >>>> <
bapt4...@googlemail.com>
> >> >> >>>> wrote:
>
> >> >> >>>>> On Sep 13, 2010, at 2:49 PM, Brandon Hurr wrote:
>
> >> >> >>>>> I've never actually looked at the guts of a geom_* before... how
> >> >> >>>>> much
> >> >> >>>>> motivation are we talking about?
>
> >> >> >>>>> Making a rough new geom is quite doable, the major steps are
> >> >> >>>>> summarized
> >> >> >>>>> here:
> >> >> >>>>>
http://github.com/hadley/ggplot2/wiki/Creating-a-new-geom
> >> >> >>>>> However, making a *good* geom is another story :)
> >> >> >>>>> In the case ofpatternfills one would probably have to define
> >> >> >>>>> new
> >> >> >>>>> scales as well to map thepatterndensity and orientation.
> >> >> >>>>> baptiste
>
> >> >> >>>>> B
>
> >> >> >>>>> On Mon, Sep 13, 2010 at 13:25, baptiste Auguié
> >> >> >>>>> <
bapt4...@googlemail.com>
> >> >> >>>>> wrote:
>
> >> >> >>>>>> Hi,
> >> >> >>>>>> I think it's still the official state of affairs.
> >> >> >>>>>> There's an experimental implementation of filling patterns for
> >> >> >>>>>> Grid
> >> >> >>>>>> graphics in the gridExtra package though, with some motivation
> >> >> >>>>>> one
> >> >> >>>>>> could
> >> >> >>>>>> write a ggplot2 geom for it.
> >> >> >>>>>> library(gridExtra)
> >> >> >>>>>> example(patternGrob)
> >> >> >>>>>> HTH,
> >> >> >>>>>> baptiste
> >> >> >>>>>> On Sep 13, 2010, at 2:18 PM, Brandon Hurr wrote:
>
> >> >> >>>>>> Last thing I could find about it says no.
> >> >> >>>>>>
http://www.mail-archive.com/r-h...@r-project.org/msg74619.html
>
> >> >> >>>>>> Unfortunately grid (the underlying graphics library that ggplot2
> >> >> >>>>>> uses)
> >> >> >>>>>> does not currently support patterns.
>
> >> >> >>>>>> Hadley
>
> >> >> >>>>>> That was November 2009 though...
> >> >> >>>>>> Brandon
> >> >> >>>>>> On Mon, Sep 13, 2010 at 11:04, dM/ <
david.n.mene...@gmail.com>
> >> >> >>>>>> wrote:
>
> >> >> >>>>>>> Hi
>
> >> >> >>>>>>> I'm new to the group, so sorry if this has been asked before.
> >> >> >>>>>>> Is
> >> >> >>>>>>> it
> >> >> >>>>>>> possible to produce a histogram where the fill is not just a
> >> >> >>>>>>> solid
> >> >> >>>>>>> colour, but has apatternfill? (patternfill - e.g. red
> >> >> >>>>>>> diagonal
> >> >> >>>>>>> stripes on a white background)
>
> >> >> >>>>>>> I'm asking, because in the chart I'm working on, (using
> >> >> >>>>>>>scale_fill_manual) it can be hard to pick distinctive colours.
>
> >> >> >>>>>>> Also, if it is possible topatternfill, is there a way to
> >> >> >>>>>>> combine
> >> >> >>>>>>> it
> >> >> >>>>>>> efficiently with solid colours? e.g. I'd like to display four
> >> >> >>>>>>> bars
> >> >> >>>>>>> in
> >> >> >>>>>>> a chart, where
>
> >> >> >>>>>>> - bar 1 = "expected financial loss" - solid colour = red
> >> >> >>>>>>> - bar 2 = "actual financial loss"patternfill, colour = red
> >> >> >>>>>>> diag
> >> >> >>>>>>> strips on solid white background
> >> >> >>>>>>> - bar 3 = "expected borrowing costs" - solid colour = blue
> >> >> >>>>>>> - bar 4 = "expected borrowing costs"patternfill, colour =
> ...
>
> Erfahren Sie mehr »