For this reason, you need to put fill=task_color inside aes(). In other words, the value of task_color should be mapped to the plot, which you need to do using aes(.). Since task_color is a column in your dataset, the value depends on the particular observation in your dataset. I cannot seem to load your data frame (good that you tried, but perhaps a bit difficult with polygon information), but perhaps the issue is related to referencing to apply the fill= outside of aes() via fill=task_color. How do I get each grid cell filled with the color in the task_color color column? Thank you. Geom_path(grid, mapping = aes(x = long, y = lat, group = group), size = 2.5, alpha = 0.30, col = 'pink') + geom_polygon(data = grid, mapping = aes(x = long, y = lat, group = group), alpha = 0.30, fill = task_color) Here is a small portion of the polygon data: library(ggplot2) library(raster) library(sp) library(rgdal) However, I keep getting errors that tell me the object "task_color" is not found. I would like to be able to color each grid cell (polygon) by the task_color column in the SpatialPolygonsDataFrame. I have a map of grid cells containing information in each cell, such as name, description, task_order, and task_color.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |