1

I am trying to zoom the plot that I have got. But i couldn't find any proper result. Here is my original plot!

plt <- ggplot(Df, aes(x = Lon, y = Lat, colour = AC), pch = 17) +geom_point()
plt + geom_path(arrow= arrow(), colour="grey") + scale_size(range = 1)

I have tried to do it using dygraph, zoom packages but couldn't succeed. Note that I do not want to use xlim and ylim over here.

ayush
  • 343
  • 3
  • 20
  • If you do not want to use xlim or ylim, please define what you do mean by zooming. – Axeman Jun 22 '15 at 12:04
  • @Axeman i mean, if u can see the graph, it is very dense at different points. xlim and ylim does give me zoomed plot but its only for a section not for the whole graph. I want to zoom the whole plot not just the section – ayush Jun 22 '15 at 12:17
  • Do you mean saving the plot in a larger resolution / size? You could use `ggsave` and play around with the `width` and `height` parameters. – Daniel Jun 22 '15 at 12:43
  • is this [answer by Tyler Rinker](http://stackoverflow.com/questions/25685185/limit-ggplot2-axes-without-removing-data-outside-limits-zoom) what you are looking for? – RHA Jun 22 '15 at 19:39
  • @RHA yes, i kind of looking for that.. But its not exactly what I am looking for. how do I zoom the whole graph. its given only for the ylim ? I want to zoom the whole graph. like as google earth does. – ayush Jun 23 '15 at 04:32
  • So if i'm correct you want to have the whole graph, but be able to zoom in and out on the areas with dense points? Then the best option i know is to make your points smaller and save it to vector format (for example pdf) with high resolution. Then you can zoom in and out with acrobat reader. – RHA Jun 23 '15 at 06:34
  • @RHA isn't there similar any option in R? – ayush Jun 23 '15 at 14:12
  • Ah, you just want to be able to zoom in and out in the window where R displays the graph. As far as i know, that is not possible. R-studio has a zoom function, but it is limited. However, there is a possibility in R studio, that i think will suit you're needs. I will add that as an answer. – RHA Jun 23 '15 at 18:39

3 Answers3

4

If i understand correctly, you want to zoom in and out in the graphics device (window) and not zoom the plot itself, as is shown here Limit ggplot2 axes without removing data (outside limits): zoom

Probably you're best bet is still the zoom package. This package has several functions that may be useful to you, like inout.zoom() and sq.zoom(). If this doesn't work for you, please be more specific of what it doesn't do.

R-studio offers some options: 1. There is a zoom button above the plot window, that shows the graph in a bigger window. I some cases this will be enough, however in your case it will not be because you have many points cluttered together. 2. In R-studio, press EXPORT-SAVEtoPDF-PREVIEW. This will open a preview in acrobat reader where you can zoom in and out as much as you like.

Community
  • 1
  • 1
RHA
  • 3,677
  • 4
  • 25
  • 48
  • thank you for the answer. It could be one of the method but it'll be hard to find the points exact position after zooming the image. Isn't there any way that I can scale up or scale down my plot(axis) when i zoom in or zoom out? – ayush Jun 24 '15 at 02:35
  • Then i think you should be looking at the zoom package (again), see my edited answer. If that doesn't work for you, please specify what it doesn't do. – RHA Jun 24 '15 at 15:27
0

What I do in this case is render it additionally to a png file at high resolution and then I can examine it with other tools at my leisure. Code with filename and 1000x1000 resolution is like this:

   gfname <- sprintf("plotname-%d.png",version)
   png(gfname,width=1000,height=1000)
   print(plt)
   jnk <- dev.off()
Mike Wise
  • 22,131
  • 8
  • 81
  • 104
0
ggsave(p,filename=mypath,width=13.66,height=7.05,limitsize = FALSE) 

worked for me in getting the zommed plots saved within a loop. p- plot