Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top