0

I am plotting a graph using ggplot2. It has background image as my screen wall paper I want to plot graph over it and render it as png image.And I want my graph to fit on my computer screen.How can I do that.When I am plotting it scales the image to smaller to fit in the graph!!

b <-readPNG("ao.png")
p <- ggplot(mydata, aes(ms,x=x,y=-y)) + background_image(b) +
  geom_path(color='blue') + geom_point(color='blue')
p

I am using this code, image is screen-shot of my screen and in the output it is scaled to fit into the graph!

Nurav
  • 167
  • 1
  • 3
  • 15
  • Does this answer your question? [Inserting an image to ggplot2](https://stackoverflow.com/questions/9917049/inserting-an-image-to-ggplot2) – tjebo Jul 01 '20 at 09:05
  • I know how to insert image in background I want to render it in png format and that png should have x and y axis coinciding with screen rectangle – Nurav Jul 01 '20 at 09:53
  • E.g. https://stackoverflow.com/questions/44711236/set-the-size-of-ggsave-exactly – tjebo Jul 01 '20 at 12:31
  • you need to know your screen dimensions and the resolution that you are using, obviously. – tjebo Jul 01 '20 at 12:32

1 Answers1

0

you could do something like

png(file="saving_plot1.jpeg",with=800,height=600) # check the parameters
p # your plot
dev.off()

or you could use the plot pane and then use "export"

sambold
  • 807
  • 5
  • 15