A plea for filling patterns

319 views
Skip to first unread message

Kasi

unread,
Apr 8, 2011, 1:26:35 PM4/8/11
to ggplot2
Hi,

I love ggplot and and many papers have figures generated by ggplot
in them However, I receive repeatedly push back from the reviewers and
also the copy editors that the colour figures don't work well with
black&white printing.

- I know that the problem doesn't reside with ggplot itself.
- I understand that the source code is open and I could in theory add
it myself.
- I understand that ggplot is free and I have to take it as is it.

Still—please register another vote in support of 'filling patterns'.

Are there any plans for it? Is there any light work (beta testing)
where one can help?

Thanks.

Dennis Murphy

unread,
Apr 8, 2011, 2:00:49 PM4/8/11
to Kasi, ggplot2
Have you tried scale_grey() instead of color?

Dennis


--
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

Kasi

unread,
Apr 8, 2011, 6:42:17 PM4/8/11
to ggplot2
Using scale_grey() unfortunately doesn't scale. For example try
matching a bar to an item with ten levels of grey.

Many suggestions in the forums are either incomplete (not for general
polygons) or impractical. So let me add two more: (1) export from R to
tikz and then manually replace the colours with patterns, (2) export
from R and use gnuplot for figures where it matters. I want to go
neither of the two routes.

Ista Zahn

unread,
Apr 8, 2011, 7:07:51 PM4/8/11
to Kasi, ggplot2
Matching 10 fill patterns would probably also be unsatisfactory. You
can probably get 4 (maybe 5) easily distinguished levels out of
scale_gray, e.g., white, light gray, dark gray, black. I think most
pattern fills would become pretty awful with more than 5 or five
patterns anyway.

Best,
Ista

--
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

Bill Harris

unread,
Apr 8, 2011, 10:02:48 PM4/8/11
to Kasi, ggplot2
Kasi <pop...@gmx.net> writes:

> Using scale_grey() unfortunately doesn't scale. For example try
> matching a bar to an item with ten levels of grey.

While 10 sounds like a lot, have you looked at colorbrewer and its
printer-safe color schemes?

Bill
--
Bill Harris http://makingsense.facilitatedsystems.com/
Facilitated Systems Everett, WA 98208 USA
http://www.facilitatedsystems.com/ phone: +1 425 374-1845

martin_kaercher

unread,
Apr 11, 2011, 4:42:18 AM4/11/11
to ggplot2
Dear all,

In my view Kasi is right. I once wrote a similar plea in reply to a
previous discussion, however, without success ;-):

https://groups.google.com/group/ggplot2/browse_thread/thread/ca546f7f4d636deb/ae7bf7689667ecbe?hl=de&lnk=gst&q=black+and+white+patterns#ae7bf7689667ecbe

I think the key thing is that if someone, maybe one of Hadley's Master
students (hint, hint), implements black and white patterns to ggplot
they have to be simple and elegant, like ggplot, not as clumsy as in
Excel.

Cheers,

Martin



On 9 Apr., 03:02, Bill Harris <bill_har...@facilitatedsystems.com>
wrote:
> Kasi <pop...@gmx.net> writes:
> > Using scale_grey() unfortunately doesn't scale. For example try
> > matching a bar to an item with ten levels of grey.
>
> While 10 sounds like a lot, have you looked at colorbrewer and its
> printer-safe color schemes?
>
> Bill
> --
> Bill Harris                  http://makingsense.facilitatedsystems.com/
> Facilitated Systems                              Everett, WA 98208 USAhttp://www.facilitatedsystems.com/              phone: +1 425 374-1845

baptiste auguie

unread,
Apr 11, 2011, 6:12:46 AM4/11/11
to ggplot2
Hi,

It seems to me that the issue isn't really with ggplot2 but rather at
a much lower level, with grid, or even its interaction with R graphic
devices. Thus, it would make more sense to discuss it on R-help or
R-devel. It might be possible to tweak grid a little and simply use
already-existing patterns on devices that support them natively
(Cairo, tikzDevice, SVG perhaps).

baptiste

Hadley Wickham

unread,
Apr 11, 2011, 9:44:19 AM4/11/11
to baptiste auguie, ggplot2
> It seems to me that the issue isn't really with ggplot2 but rather at
> a much lower level, with grid, or even its interaction with R graphic
> devices. Thus, it would make more sense to discuss it on R-help or
> R-devel. It might be possible to tweak grid a little and simply use
> already-existing patterns on devices that support them natively
> (Cairo, tikzDevice, SVG perhaps).

For statistical graphics, I think we also need a good way of
specifying a useful set of patterns with good perceptual properties.
I would think the place to start would be with sets of lines at
various angles and spacings, but I'm not aware of any work in this
area.

Hadley


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

JiHO

unread,
Apr 13, 2011, 5:54:52 AM4/13/11
to Kasi, ggplot2
On Sat, Apr 9, 2011 at 00:42, Kasi <pop...@gmx.net> wrote:
> Many suggestions in the forums are either incomplete (not for general
> polygons) or impractical. So let me add two more: (1) export from R to
> tikz and then manually replace the colours with patterns,

I understand this will seem like an impractical solution too but at
least it is an easy enough workaround:
- use a colour scale
- export the plot to PDF or SVG
- open and modify it in Inkscape
- export PDF or EPS or whatever the publisher wants (they will
probably stupidly ask for 600dpi TIFFs) from Inkscape

Inkscape comes with functionality that will make the modifications easy"ish".

Selecting elements of the same colour
- select one element of a given colour
- right click on the colour swatch at the bottom left of the window
- select "Copy colour"
- Edit > Find (Ctrl+F)
- in the "Style" section, paste the colour (Ctrl+V)
- click "Find" or press "Enter"
This will select all elements with this colour in the plot. You can
edit them all at once (change their colour, fill them with a pattern,
etc.). To "save" this selection, just group the elements (Edit >
Group, Ctrl+G). You can later select the group and apply a certain
style to it.

Applying and modifying a pattern
- select an element
- in the fill and stroke panel, select a pattern
- select the node tool (second from top)
- handles appear at the top left of the page, they modify the pattern
- the square handle modify the size of the pattern, the round one
modifies the rotation

Applying the same style to several elements
- select the element with the style you want
- Edit > Copy (Ctrl+C)
- select all other elements you want the style applied to
- Edit > Paste style (Ctrl+Shift+V)
You can select one element inside a group by Ctrl+clicking on it,
modify it, copy it, then click elsewhere to clear the selection, click
on the group and paste style. The whole group will get the new style
you just defined.

Creating a pattern
- draw something on the canvas
- when this something has several elements, group them
- select the just created object/group and Object > Pattern > Object
to pattern (Alt+I)
- select an object you want to apply the pattern to
- in the Fill and Stroke dialog, select the new pattern in the pattern
list. It should be named something like "pattern12345"
The pattern will be repeated based on the bounding box of the original
object. So, as a rule of thumb, when designing a pattern, try to have
it fit in a rectangle. You will be able to modify its size and
orientation with the node tool after the pattern is applied anyway.

This might all seem complex but really, once you get the hang of how
Inkscape works, handles objects etc. it is very easy and quite fast.
Inkscape is remarkably consistent so, even if it is a powerful piece
of software, it should be easy to learn.


Reproducible research principles say you shouldn't do this. Practical
requirements show that, for me at least, it is much faster to get
decent enough plots from ggplot, choose among them and then polish the
few that will make it in the paper in Inkscape, even if I have to redo
the polishing once or twice because I redid the plot. There are things
like changing fonts, highlighting a part of a plot, rearranging the
legend, modify the spacing between plot elements that are only
reasonably done in an external software.

That's my two cents.

JiHO
---
http://maururu.net

Reply all
Reply to author
Forward
0 new messages