What device are you using? I've attached the output I get when saving
to a png on my mac. I think all cairo-based devices should give
similar results.
Hadley
What device are you using? I've attached the output I get when saving
to a png on my mac. I think all cairo-based devices should give
similar results.
> What device are you using? I've attached the output I get when saving
> to a png on my mac. I think all cairo-based devices should give
> similar results.
saving to png on a mac uses the quartz device (i.e. png(...,
type="quartz") ).
Forcing the cairo device (which is the default for both display and
raster rendering on linux and in X11 on mac) shows the antialiasing
problem.
library(ggplot2)
cond <- LETTERS[1:25]
xval <- 0:24 %% 5
yval <- 5*floor(0:24 / 5)
df <- data.frame(cond, xval, yval)
p <- ggplot(df, aes(x=xval, y=yval, shape=cond)) +
geom_point(fill="red", size=4) + scale_shape_manual(values=0:25)
png("mac.png")
print(p)
dev.off()
png("mac-cairo.png", type="cairo")
print(p)
dev.off()
(for some reason, cairo based rendering is very slow on my MacBook. I
don't know where it gets its Cairo library from).
JiHO
---
http://jo.irisson.free.fr/
I have the same problem on Linux, using the Cairo device. I guess the
problem is that the shapes are filled, not stroked, and that Cairo
antialiasing doesn’t work properly then.
--
Karl
?X11 says:
Anti-aliasing is only supported for cairo-based devices, and
applies to graphics and to fonts. It is generally preferable for
lines and text, but can lead to undesirable effects for fills,
e.g. for 'image' plots, and so is never used for fills.
--
Karl
Ah, ok, that's some confusing documentation for png.
Unfortunately there's not much I can do about this from my end. My
only advice would be to write up a small reproducible example, submit
it to R-help and then hope that Brian Ripley has time to do something
about it.
Hadley
> Unfortunately there's not much I can do about this from my end. My
> only advice would be to write up a small reproducible example, submit
> it to R-help and then hope that Brian Ripley has time to do something
> about it.
I'm pretty sure it's intentional. See, e.g.:
http://tolstoy.newcastle.edu.au/R/e4/devel/08/05/1771.html
--
Karl Ove Hufthammer
This seems like a clear counter-example to Brian's claim that's it of no use.
Hadley
I’m not sure I understand. Isn’t it more an example of the fact the
antialiasing of fills is *usually* a bad thing, not a good thing? Here’s
another example:
us <- map("state", fill=TRUE, plot=FALSE)
plot(us, type="n", axes=FALSE, asp=1)
polygon(us, col="blue", border=NA)
No antialiasing → looks good
Antialiasing → looks bad
The example is taken from the discussion at:
http://tolstoy.newcastle.edu.au/R/devel/06/08/6391.html
--
Karl Ove Hufthammer
Polygon fills, antialiasing bad; point fills, antialiasing good?
Hadley
Sure, but internally they’re all implemented as polygons (see the
function GESymbol in src/main/engine.c), so I’m not sure how we can make
that distinction in practice. Perhaps a new option to X11.options() for
enabling antialiasing for fills (globally) could be useful, though?
--
Karl Ove Hufthammer