简体   繁体   中英

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?

在此处输入图像描述

You can change the font size of the legend using legend.text in your theme like this:

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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