无法更改R中的图例位置

问题描述 投票:0回答:1

我正在使用 R 中的代码生成此图表。

ggplotly(
 gplot(data=ComercioLineChart,aes(x=ComercioLineChart$Ano,y=ComercioLineChart$`Quantidade (L)`,color=ComercioLineChart$Categoria)) +
    geom_line(alpha = .5) + 
    geom_point(alpha = .5) +
    labs(title = "Comércio de categorias de vinhos por ano",subtitle = "1970-2016",caption = "Dados obtidos em: http://vitibrasil.cnpuv.embrapa.br/index.php?opcao=opt_01", y = "Quantidade (em milhões de litros)", x = NULL, color = "Categorias") +
    scale_y_continuous(n.breaks=10, labels = unit_format(unit = "M", scale = 1e-6)) +
    theme_bw() +
    theme(legend.position ="bottom")
    )

问题是我根本无法更改图例位置。我尝试过使用数字、“顶部”、“底部”等等。没有任何效果。

我做错了什么?

我希望图例变小并位于图表下方,这样图表就会更宽

enter image description here

r ggplot2 ggplotly
1个回答
0
投票

如果没有可重现的示例,很难说清楚,但看起来使用多个“主题”可能是问题的一部分。您是否尝试过删除

theme_bw() +
来运行代码?

© www.soinside.com 2019 - 2024. All rights reserved.