0

After reading a shapefile, I am using plot(), and am getting a plot.

But when I am using q=ggplot(), am getting a blank plot along with the message

Regions defined for each Polygons

Any idea why?

user247702
  • 23,641
  • 15
  • 110
  • 157
user2458552
  • 419
  • 2
  • 5
  • 17
  • Do you just type ggplot() and that's it? – Dason May 28 '14 at 13:42
  • I have tried using qplot(), too. as in, qplot(the file read) – user2458552 May 28 '14 at 13:44
  • 1
    Post the actual code you've used. No offense but we can't trust that you've done anything correctly if you don't show us what you actually did. – Dason May 28 '14 at 13:44
  • Perhaps you should read [ggplot2: plotting polygon shapefiles](https://github.com/hadley/ggplot2/wiki/plotting-polygon-shapefiles). The shape file must be turned into a data.frame `ggplot` is not a generic function in the way `plot` is that can translate a bunch of different class types into plots. It really only knows about data.frames. – MrFlick May 28 '14 at 18:58
  • thanks, I think I found the answer. we have to use fortify() for plotting shapefiles using ggplot. – user2458552 May 28 '14 at 20:26
  • @user2458552 Why don't you go ahead and post that as an answer and accept it to close out the question. – MrFlick May 29 '14 at 02:58

1 Answers1

2

Use fortify() to plot shapefiles using ggplot.

user2458552
  • 419
  • 2
  • 5
  • 17