Reputation: 101
ggmap(location) +
geom_density_2d(aes(long, lat), df) +
geom_point(aes(long, lat,**color = special**),alpha = 0.5,data = df)
I can not see what is different when I change color to the fill, like:
ggmap(location) +
geom_density_2d(aes(long, lat), df) +
geom_point(aes(long, lat,**fill = special**),alpha = 0.5,data = df)
what is the main difference between those two arguments?
Upvotes: 9
Views: 12471
Reputation: 2067
Generally, fill
defines the colour with which a geom is filled, whereas colour defines the colour with which a geom is outlined (the shape's "stroke", to use Photoshop language).
Points generally only have a colour and no fill, because, y'know—they're just points. However, point shapes 21–25 that include both a colour and a fill. For example:
library(tidyverse)
df = data_frame(x = 1:5, y = x^2)
ggplot(df) +
geom_point(
aes(x, y, fill = x),
shape = 21, size = 4, colour = 'red')
Here's an example with ggmap
, where both fill
and colour
are set (but not mapped to aesthetics):
library("ggmap")
us = c(left = -125, bottom = 25.75, right = -67, top = 49)
map = get_stamenmap(us, zoom = 5, maptype = "toner-lite")
df2 = data_frame(
x = c(-120, -110, -100, -90, -80),
y = c(30, 35, 40, 45, 40))
ggmap(map) +
geom_point(
aes(x, y), data = df2,
shape = 21, fill = 'blue', colour = 'red', size = 4)
But unless you're using those special shapes, if you use a point, give it a colour
, not a fill
(because most points don't have one).
Upvotes: 11
Reputation: 1162
This can't be answered much better than done so here.
The only reason I haven't marked this as duplicate as you're asking a slightly different question. They were experiencing what they thought was a bug, you are experiencing what you think is a no change.
In summary, there are several shapes you can choose for geom_point and only some of them have a fill and colour argument.
In general fill
changes the colour within shapes, and colour
changes the outline.
Upvotes: 3