r-lib / svglite

A lightweight svg graphics device for R
https://svglite.r-lib.org
180 stars 39 forks source link

Transparency, color fidelity #35

Closed jannaf closed 9 years ago

jannaf commented 9 years ago

Writing to the SVG changes the colors in non-workable ways. Github isn't letting me add the image files here but I have a .svg and .pdf example I can email.

hadley commented 9 years ago

Could you please include some R code that you use to create the plot?

jannaf commented 9 years ago

Is this okay? I didn't include the data and I'm not sure it makes sense without it.

plut <- data.frame(Name=mean$Name,Cluster=mean$Cluster,Species=mean$Species,Size=mean$Size,Stage=as.numeric(mean$Stage),Mean=mean$mean,Se=se$se)

selected = c("let-7","mir-2225","mir-49","mir-7601") out <- plut[plut$Name %in% selected,] q <- ggplot(out,aes(x=Stage,y=Mean,col=Species)) limits <- aes(ymax = Mean+Se, ymin=Mean-Se)

p <- ggplot(plut,aes(x=Stage,y=Mean,col=Species))

q <- ggplot(out,aes(x=Stage,y=Mean,col=Species))

p.seed <- p + facet_grid(.~Cluster) + stat_smooth(aes(fill=Species,size=Size)) + theme_classic() + scale_fill_manual(values=c("darkorchid3","darkolivegreen4"),guide=FALSE) + scale_size(range = c(0.1, 1.0)) + scale_colour_manual(values=c("darkorchid3","darkolivegreen4")) + xlab("Developmental Stage") + ylab("Normalized Expression") + scale_x_discrete(breaks=c("2","4","6"),labels=c("L2","Early L4","Young Adult")) + guides(colour="legend",size="none",shape="legend") + guides(colour=guide_legend("Species"),fill=guide_legend("Species")) + theme(legend.justification=c(1,1), legend.position=c(1,1)) + theme(text=element_text(size=12))

q.seed <- q + facet_grid(.~Cluster) + geom_line() + geom_pointrange(limits) + scale_fill_manual(values=c("darkorchid3","darkolivegreen4"),guide=FALSE) + scale_colour_manual(values=c("darkorchid3","darkolivegreen4")) + xlab("Developmental Stage") + ylab("Normalized Expression") + scale_x_discrete(breaks=c("2","4","6"),labels=c("L2","Early L4","Young Adult")) + theme(legend.position="none") + theme(text=element_text(size=12))

devSVG(file=“significant_by_two.svg", width=16, height=8.0) plot_grid(p.seed, q.seed, labels=c("A","B"), nrow=2, align="v") dev.off()

hadley commented 9 years ago

I created an example with a built in dataset and couldn't see a problem:

library(ggplot2)

htmlSVG({
  print(
    ggplot(mpg, aes(displ, cty)) + 
      geom_point() + 
      geom_smooth()
    )
})