0

I'm trying to make a plot of a shape file, where the polygons are fill by the value of one column.

I used this code :

Groups <- readOGR(".", layer="Grid_GroupMean1")
ggShape <- ggplot(data = Groups, aes(x=long, y=lat, group = group, fill = Groupr))+ geom_polygon() +geom_path(color = "white")
print(ggShape)

The level of the factor "Groupr" is 5 (O,1,2,3,5,6). There is a lot of Zeros in this factor. I don't know if it's problematic.

The plot of the shape file works without the function "fill".

enter image description here

enter image description here

C. Guff
  • 418
  • 3
  • 18
  • 1
    When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Screen shots of data structures are not particularly helpful. – MrFlick Oct 16 '18 at 16:15
  • Finally, when I was searching to create a shape file for exemple, I found by myself a solution with the function fortify() : "function from ggplot2 transforms data from shapefiles into a dataframe that ggplot can understand" [http://www.kevjohnson.org/making-maps-in-r/] `Groups <- fortify(Groups, region="Groupr")` – C. Guff Oct 17 '18 at 01:34

0 Answers0