insert a plot to ggplot

48 views
Skip to first unread message

lily li

unread,
Nov 28, 2015, 2:00:04 PM11/28/15
to ggp...@googlegroups.com
Hi ggplot users,

I'm trying to insert an existing png plot to a ggplot, but it doesn't work. because the dataset is a long one, so I'm showing part of the code here. Thanks.
If this does not work, how to insert an enlarged image of the part of a ggplot to the full range of the ggplot?

library(png)
library(grid)
image1 = readPNG('path/plot.png',native=T)
rast1 = rasterGrob(image1,interpolate=T)
plot1 = ggplot()+
  geom_point(df,aes(x=date,y=value))+
  annotation_custom(rast1,xmin=0.1,xmax=0.1,ymin=0.2,ymax=0.2)
show(plot1)

lily li

unread,
Nov 28, 2015, 2:26:02 PM11/28/15
to ggp...@googlegroups.com
could anyone help me? thanks. my initial problem is: how to enlarge a small part of a ggplot, and put the enlarged part inside of the original ggplot.

Ista Zahn

unread,
Nov 28, 2015, 4:12:21 PM11/28/15
to lily li, ggplot2

Several possibilities are described in http://stackoverflow.com/questions/20708012/embedding-a-subplot-in-ggplot-ggsubplot

Best,
Ista

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages