When editing a png output in Gimp I noticed that the legend eats into
about 3 pixels worth of the grid space. This changes the color from
grey to white and breaks up the straight edging. Subtle but
noticeable.
Here is the code I used:
#######################
filedt <- format(Sys.time(), "%m%d%H%M") # Get timestamp for files
# define plot variables
sxco <- scale_x_continuous(limits=c(0,100))
syco <- scale_y_continuous(limits=c(0,1))
lget <- scale_colour_hue("Stock")
xlab <- "Time (years)"
clabsext <- labs(x=xlab, y="Probability of Extinction")
# extinction #
p1n <- ggplot(data=cextn, aes(x=fyear,y=risk, colour=dataset),
colour="Stock")
p1n <- p1n + geom_line() + sxco + syco + clabsext + lget
imgnm <- paste("./output/","Pres CDF Ext N ", filedt, ".png", sep =
"")
ggsave(imgnm, width = 7.5, height = 5)
#######################
Thanks,
Darren
I am seeing that too with the latest version of ggplot. Simpler code:
qplot(0,0) + geom_point(aes(colour="red"))
ggsave("test.png")
reported as issue 71: http://github.com/hadley/ggplot2/issues/issue/71
JiHO
---
http://maururu.net
I dug this up from the list archives, it looks like it's still relevant,
The small overlap with the plot area for position="right" seems to
occur only for half a line width. A quick and dirty workaround would
be to shift the frame by this amount,
p <- ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot(aes(fill = factor(am))) +
opts(legend.background = theme_rect(size=5))
p
theme_rect2 <-
function (fill = NA, colour = "black", size = 0.5, linetype = 1)
{
structure(function(x = 0.5, y = 0.5, width = 1, height = 1,
...) {
rectGrob(unit(x, "npc") + 0.5*unit(size *ggplot2:::.pt, "pt"), y,
width, height, ..., gp = gpar(lwd = size *
ggplot2:::.pt, col = colour, fill = fill, lty = linetype))
}, class = "theme", type = "box", call = match.call())
}
p +
opts(legend.background = theme_rect2(size=5))
Best,
baptiste
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2
opts(legend.background=theme_rect(colour=NA))
Thanks,
Darren