【问题标题】:ggplotly() is overriding some ggplot theme() arguments. Does anyone know how to stop this?ggplotly() 覆盖了一些 ggplot theme() 参数。有谁知道如何阻止这个?
【发布时间】:2021-10-27 23:34:11
【问题描述】:

基本上我希望我的情节背景与元情节的颜色相同,当我使用 ggplotly() 包装器时不会执行。带有(第一)和不带 ggplotly 的图像。代码如下:

#ggplotly(
        df %>%
        filter(!is.na(Boxoffice)&!is.na(Decade))%>%
        ggplot(aes(x=Boxoffice,y=IMDb.Score))+
        geom_point(aes(text=Title),size=2,alpha=0.3,color = "#DB5461")+
        theme_aes()+
        facet_wrap(~Decade)+
        theme_aes()+
        theme(plot.background = element_rect(fill="#f0f0f0",color="#b4b4b4"))
        #)

【问题讨论】:

  • theme_aes() 是什么?

标签: r ggplot2 ggplotly


【解决方案1】:

再次从 plot_ly 对象中移除背景;

library(tidyverse)
library(plotly)


iris %>%
ggplot(aes(x=Sepal.Width,y=Sepal.Length))+
geom_point(size=2,alpha=0.3,color = "#DB5461")+
facet_wrap(~Species)+
theme(plot.background = element_rect(fill="#f0f0f0",color="#b4b4b4"),panel.background = element_blank()) -> ggobj

plotlyobj <- ggplotly(ggobj)


ggobj

plotlyobj %>%layout(plot_bgcolor='rgba(0,0,0,0)')

【讨论】:

    猜你喜欢
    • 2016-12-04
    • 2022-01-17
    • 2020-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-14
    • 1970-01-01
    相关资源
    最近更新 更多