Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R ggplotly主题与ggplot2不一致_R_Ggplot2_Themes_Ggplotly - Fatal编程技术网

R ggplotly主题与ggplot2不一致

R ggplotly主题与ggplot2不一致,r,ggplot2,themes,ggplotly,R,Ggplot2,Themes,Ggplotly,嗨,我正在使用ggplotly添加互动性,我正在使用ggplot2制作一个闪亮的仪表板。绘图功能正常,只是看起来很傻,因为它没有始终使用我通常使用的主题(theme_jacob())。我知道在ggplot上应用plotly函数时会遇到很多问题,但我无法在线找到任何资源来解决我的特定问题。我已将代码粘贴到下面 theme_jacob <- function () { theme_minimal(base_size=10, base_family="Gill Sans MT") %+re

嗨,我正在使用ggplotly添加互动性,我正在使用ggplot2制作一个闪亮的仪表板。绘图功能正常,只是看起来很傻,因为它没有始终使用我通常使用的主题(theme_jacob())。我知道在ggplot上应用plotly函数时会遇到很多问题,但我无法在线找到任何资源来解决我的特定问题。我已将代码粘贴到下面

theme_jacob <- function () { 
  theme_minimal(base_size=10, base_family="Gill Sans MT") %+replace% 
    theme(
      panel.grid.minor = element_blank(),
      plot.background = element_rect(fill = 'floralwhite', color = 'floralwhite')
    )
}

  p <- df %>%
    ggplot(aes(valence, energy, color = album_name, text = paste(track_name, '<br>', album_name, '<br>',
                                                                 'Positivity ', round(valence, 2), '<br>',
                                                                 'Energy ', round(energy, 2)))) +
    geom_point(size = 2, alpha = 0.8) +
    geom_hline(yintercept = 0.5) +
    geom_vline(xintercept = 0.5) +
    scale_x_continuous(limits = c(0, 1), breaks = seq(0, 1, .1)) +
    scale_y_continuous(limits = c(0, 1), breaks = seq(0, 1, .1)) +
    annotate('text', x = 0.99, y = 1, label = 'Happy / Upbeat') +
    annotate('text', x = 0.99, y = 0, label = 'Mellow / Peaceful') +
    annotate('text', x = 0.01, y = 0, label = 'Sad / Slow') +
    annotate('text', x = 0.05, y = 1, label = 'Aggressive / Fast Paced') +
    labs(x = "Positivity",
         y = "Energy",
         color = 'Album',
         title = paste(df$artist_name, ' Song Distribution', sep = ""),
         caption = paste('Data collected via spotifyr Package on ', mdyDate, sep = "")) +
    theme_jacob() +
    theme(legend.position = 'top')
  ggplotly(p, tooltip = c('text')) %>%
    layout(title = list(text = paste0(paste(df$artist_name, ' Song Distribution', sep = ""))))

theme\u%
布局(标题=列表(文本=粘贴0(粘贴(df$artist_name,'歌曲发行',sep=”“))
下面是一个图的示例,它是扭曲的,但在我闪亮的仪表板中大小正确。你可以看到它到处都在使用我的主题,除了实际的情节,它变成了默认的白色背景和idk如何修复。如果有人有任何建议,我将不胜感激


您需要在
主题中使用语句
panel.background=element\u rect(fill=“floralwhite”)
。这应该行。

您需要在
主题中使用语句
panel.background=element\u rect(fill=“floralwhite”)
。这应该行得通