このコードによって生成された凡例から文字「a」を削除するにはどうすればよいですか?を削除するgeom_textと、凡例に「a」の文字が表示されません。でも守りたいgeom_text。
ggplot(data = iris, aes(x = Sepal.Length, y=Sepal.Width, shape = Species, colour = Species)) + 
   geom_point() + 
   geom_text(aes(label = Species))このコードによって生成された凡例から文字「a」を削除するにはどうすればよいですか?を削除するgeom_textと、凡例に「a」の文字が表示されません。でも守りたいgeom_text。
ggplot(data = iris, aes(x = Sepal.Length, y=Sepal.Width, shape = Species, colour = Species)) + 
   geom_point() + 
   geom_text(aes(label = Species))回答:
設定するshow.legend = FALSEにはgeom_text:
ggplot(data = iris,
       aes(x = Sepal.Length, y = Sepal.Width, colour = Species, shape = Species, label = Species)) + 
    geom_point() +
    geom_text(show.legend = FALSE)引数のshow_guide名前がshow.legendinに変更されましたggplot2 2.0.0(リリースニュースを参照)。
プレggplot2 2.0.0:
show_guide = FALSEようなので...
ggplot( data=iris, aes(x=Sepal.Length, y=Sepal.Width , colour = Species , shape = Species, label = Species ) , size=20 ) + 
geom_point()+
geom_text( show_guide  = F )
ニックが言ったように
次のコードでもエラーが発生します。
geom_text(aes(x=1,y=2,label="",show_guide=F))一方:
geom_text(aes(x=1,y=2,label=""),show_guide=F)aes引数の外では、伝説上のaが削除されます
guide_legend(override.aes = aes(...))凡例の「a」を非表示にするために使用できます。
以下は、guide_legend()の使用例です。
library(ggrepel)
#> Loading required package: ggplot2
d <- mtcars[c(1:8),]
p <- ggplot(d, aes(wt, mpg)) +
  geom_point() +
  theme_classic(base_size = 18) +
  geom_label_repel(
    aes(label = rownames(d), fill = factor(cyl)),
    size = 5, color = "white"
  )
# Let's see what the default legend looks like.
p
# Now let's override some of the aesthetics:
p + guides(
  fill = guide_legend(
    title = "Legend Title",
    override.aes = aes(label = "")
  )
)
reprexパッケージ(v0.2.1)によって2019-04-29に作成されました
show.legend = FALSEの引数geom_label_repel()で、凡例の「a」を削除することもできます。したがって、代わりに
ggplot(d, aes(wt, mpg)) +
  geom_point() +
  theme_classic(base_size = 18) +
  geom_label_repel(
    aes(label = rownames(d), fill = factor(cyl)),
    size = 5, color = "white"
  )+ guides(
  fill = guide_legend(
    title = "Legend Title",
    override.aes = aes(label = "")
  )
)できるよ、
ggplot(d, aes(wt, mpg)) +
  geom_point() +
  theme_classic(base_size = 18) +
  geom_label_repel(
    aes(label = rownames(d), fill = factor(cyl)),
    size = 5, color = "white",
    show.legend = FALSE  )同様の問題があり、ラベルを付けようとしたさまざまな色の付いたポイントの後ろに「a」が表示されましたgeom_text_repel。「a」を削除して、「a」の後ろにポイントがないようにするにshow.legend=FALSEは、に引数として追加する必要がありましたgeom_text_repel。
同じ問題で苦労している可能性のある人なら誰でも理解できることを願っています!
show.legendさFALSEれggplot2ます。