R: using hatched fill in plots
Asked Answered
B

3

5

I was using R to make some plots for a report. I see that the plots don't seem to be so smooth. I am new to R so don't know much. But how do I get smooth plots?

Also by default the plots are filled with solid colors but I want to have hatched fills in my pie charts and bar plots. Is there a way to do that in R, I couldn't find it through a basic google search so I put this question here.

Birr answered 20/12, 2010 at 13:54 Comment(5)
FYI: The attitude of the graphics gurus in R is very negative toward hatching because it has un-natural effects on human perception. They intentionally make it difficult to use hatching because they think it distorts the understanding of the data and detracts from the visual quality of the display. (They are also very "down" on pie charts.) Jim Lemon who has done many of the plotrix programs is perhaps the most tolerant on those points.Kamchatka
You will have to clarify what do you mean by "not so smooth". Are you saving the plot to a file? What format? etcDarsey
@Dwin thanks for this insight, it's just that I saw one report (recent) that used hatching and somehow to me it looked visually more appealing and wanted to give it a try. I'd like to read more about why pie chart and not preferred.Birr
@Darsey that was a rookie mistake on my part, the jaggedness seems to be present only when I plot the figures within the R console, when I saved it as an pdf they looked fine :).Birr
The persons who are most famous for their work on creating good graphics are Cleveland and Tufte. Cleveand wrote "Visualizing Data" and Tufte has written several books, the first of which was "The Visual Display of Quantitative Information". He's famous for his entertaining attacks on chart-junk from Excel.Kamchatka
I
6

Did you try help(pie)?

density: the density of shading lines, in lines per inch.  The default
          value of ‘NULL’ means that no shading lines are drawn.
          Non-positive values of ‘density’ also inhibit the drawing of
          shading lines.

pie(c(1,2,3),density=c(1,2,20))

hist(runif(200),density=c(10,20,30))
Isopod answered 20/12, 2010 at 13:58 Comment(0)
H
5

Note that cross hatching and filling with lines is a hold over from the days when the only way to get quality graphics was with pen plotters (devices that literally drew the plot using a mechanical arm and a pen). Solid fills did not work well on those devices, often making holes in the paper when trying.

Now with high quality monitors and printers, solid fills are prefered, in fact research has shown that cross hatching can cause optical illusions due to the Moire effect, so are best avoided.

Pie charts are also best avoided, the only thing they do better than bar charts is hide and obscure data. Dotplots are becoming prefered to bar charts and with dotplots you don't need to worry about fills.

I know this does not answer the question you asked, but it does answer the one you should have asked.

Husein answered 20/12, 2010 at 18:6 Comment(1)
thanks for the insights, I know that its not the norm to use hatched fills nowadays but was just curious because I saw one report where it seemed visually appealing to me. Can you elaborate as to why pie charts and bar charts aren't preferred? That view seems intriguing to me.Birr
C
1

The idea that hatching should be consigned to the history books is all well and good, but there are still situations where you have to use hatching rather than solid fills - i.e. when you have to present something in black and white. Many academic journals, for instance, still only have black and white figures so using solid fills isn't an option if you want to do a stack chart with more than a few options.

Crushing answered 18/5, 2013 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.