简体   繁体   English

R:如何在 plotly/ggplotly 中控制图例图的字体大小?

[英]R: How to control font size of legend map in plotly/ggplotly?

How can I control the font size of the legend map in plotly/ggplotly?如何在 plotly/ggplotly 中控制图例地图的字体大小?

在此处输入图像描述

You can change the font size of the legend using legend.text in your theme like this:您可以在theme中使用legend.text更改图例的字体大小,如下所示:

library(dplyr)
library(ggplot2)
library(plotly)
p <- iris %>%
  ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
  geom_point() +
  theme(legend.text=element_text(size=3))

ggplotly(p)

p <- iris %>%
  ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
  geom_point() +
  theme(legend.text=element_text(size=15))

ggplotly(p)

Created on 2022-07-15 by the reprex package (v2.0.1)reprex 包于 2022-07-15 创建 (v2.0.1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM