使用geom_count时填充美学无法正常工作

时间:2019-05-31 15:44:29

标签: r ggplot2

我正在尝试将ggplot对象的fill设置为NA。我已经在使用类似的代码之前完成了此操作,但是由于某些原因,此代码无法正常工作。有什么想法吗?

这是我的数据:

structure(list(longitude = c(-81.09397, -81.09397, -81.09397, 
-81.09397, -81.09397, -81.15897, -81.15897, -81.15897, -81.15897, 
-81.15897, -81.15897, -81.17191, -81.17538, -81.17191, -81.17538, 
-81.17191, -81.17538, -81.17191, -81.17538, -81.17191, -81.17538, 
-81.16389, -81.17191, -81.17538, -81.17191, -81.17538, -81.17191, 
-81.17538, -81.16389, -81.17191, -81.17538, -81.16389, -81.17191, 
-81.17538, -81.16389, -81.17191, -81.16127, -81.16389, -81.17191, 
-81.16389, -81.17191, -81.16127, -81.17191, -81.17191, -81.25841, 
-81.25841, -81.25841, -81.24818, -81.25841, -81.25841, -81.25841, 
-81.25841, -81.25841, -81.24818, -81.25841, -81.25841, -81.24818, 
-81.25841, -81.25841, -81.25841, -81.24818, -81.25841, -81.24818, 
-81.25841, -81.24818, -81.25841, -81.24818, -81.25841, -81.24818, 
-81.25841, -81.24818, -81.25841, -81.24818, -81.25841, -81.26803, 
-81.24818, -81.25841, -81.24818, -81.25841, -81.24818, -81.25841, 
-81.24818, -81.23814, -81.25841, -81.24818, -81.25841, -81.24818, 
-81.24818, -81.24818, -81.24818, -81.25841, -81.24818, -81.25841, 
-81.24818, -81.24818, -81.24818, -81.24818, -81.24818, -81.25841
), latitude = c(72.35019, 72.35019, 72.35019, 72.35019, 72.35019, 
72.32544, 72.32544, 72.32544, 72.32544, 72.32544, 72.32544, 72.294, 
72.2963, 72.294, 72.2963, 72.294, 72.2963, 72.294, 72.2963, 72.294, 
72.2963, 72.29368, 72.294, 72.2963, 72.294, 72.2963, 72.294, 
72.2963, 72.29368, 72.294, 72.2963, 72.29368, 72.294, 72.2963, 
72.29368, 72.294, 72.29111, 72.29368, 72.294, 72.29368, 72.294, 
72.29111, 72.294, 72.294, 72.26846, 72.26846, 72.26846, 72.26533, 
72.26846, 72.26846, 72.26846, 72.26846, 72.26846, 72.26533, 72.26846, 
72.26846, 72.26533, 72.26846, 72.26846, 72.26846, 72.26533, 72.26846, 
72.26533, 72.26846, 72.26533, 72.26846, 72.26533, 72.26846, 72.26533, 
72.26846, 72.26533, 72.26846, 72.26533, 72.26846, 72.27166, 72.26533, 
72.26846, 72.26533, 72.26846, 72.26533, 72.26846, 72.26533, 72.26213, 
72.26846, 72.26533, 72.26846, 72.26533, 72.26533, 72.26533, 72.26533, 
72.26846, 72.26533, 72.26846, 72.26533, 72.26533, 72.26533, 72.26533, 
72.26533, 72.26846)), class = "data.frame", row.names = c(36499L, 
36501L, 36518L, 36527L, 37049L, 37812L, 37816L, 37818L, 37820L, 
37826L, 37829L, 37943L, 37944L, 37945L, 37946L, 37947L, 37948L, 
37950L, 37951L, 37953L, 37954L, 37955L, 37956L, 37957L, 37958L, 
37959L, 37960L, 37961L, 37962L, 37963L, 37964L, 37966L, 37967L, 
37968L, 37969L, 37971L, 37972L, 37973L, 37974L, 37975L, 37976L, 
37977L, 37978L, 37979L, 37990L, 38007L, 38014L, 38016L, 38017L, 
38023L, 38028L, 38031L, 38032L, 38036L, 38037L, 38041L, 38042L, 
38045L, 38048L, 38049L, 38052L, 38053L, 38054L, 38055L, 38056L, 
38057L, 38058L, 38059L, 38060L, 38061L, 38062L, 38063L, 38064L, 
38065L, 38067L, 38068L, 38069L, 38072L, 38073L, 38074L, 38075L, 
38076L, 38077L, 38079L, 38080L, 38081L, 38082L, 38083L, 38084L, 
38086L, 38088L, 38090L, 38091L, 38094L, 38095L, 38096L, 38097L, 
38098L, 38209L))

这是我当前的代码:

ggplot()+
  geom_count(data = DetsIND, aes( x = longitude, y = latitude), color = 'black', fill = NA)+
  xlim(-81.4, -80.55)+ ylim( 72.2, 72.7)

1 个答案:

答案 0 :(得分:1)

默认形状19没有填充,因此将忽略该参数。

path(P) :- length(P, L), L >= 2, (path(P, L) *-> true ; (!, fail)).

path([X, Y], 2) :- edge(X, Y).
path([X, Y, Z | T], L) :-
  L >= 3,
  L1 is L - 1,
  edge(X, Y),
  path([Y, Z | T], L1).

# Dummy data frame df <- data.frame(x = rep(1, 10), y = rep(1, 10)) # Load library library(ggplot2) # Plot data g <- ggplot(df) + geom_count(aes(x, y), colour = "black", fill = NA) g 确实具有填充选项。

shape = 1

reprex package(v0.3.0)于2019-05-31创建

页面here的底部可以找到形状的完整列表。