2017-12-31 218 views
1

ggmapにはgeom_pointのプロットがあり、点の形状と塗りつぶしと色を一定に保つために別々のスタイリングがあります。ここでは、コードです:ggplot2の凡例の塗りつぶし値が正しくありません

ggmap(m) + 
geom_point(data = d, 
      aes(x = Longitude, y = Latitude, fill = Phylum, shape = Placecount), 
       colour = 'black', size = 2) + 
scale_shape_manual(values = c(21,22)) 

結果は「門」が誤って全体に黒に関連付けられている伝説を除いて満足のいくものです。

enter image description here

+0

から= '黒' 色を削除エース() –

+0

@ EdwardMendez、それは役に立たなかった。 – macleginn

答えて

2

は手動形状値が+ guides(fill = guide_legend(override.aes = list(shape = 21)))であなたのフィル伝説(または任意の説明文)で使用されている調整することができます。デフォルトはshape = 1のように見えますが、これは塗りつぶしをサポートしていないため、黒い立体が得られます。ここ

mtcars有する例である:override_aes()

ggplot(mtcars) + 
    geom_point(aes(hp, mpg, fill = as.factor(cyl), shape = as.factor(am))) + 
    scale_shape_manual(values = c(21,22)) + 
    guides(fill = guide_legend(override.aes = list(shape = 21))) 

プロット:

enter image description here

プロットなし:

enter image description here

関連する問題