首页 > 解决方案 > 使用 plotly 时,绘图未显示在查看器中

问题描述

尝试以 plotly 的第一次用户身份运行一些教程代码。但是,绘图不会出现在查看器窗格中,并且会生成以下消息(在查看器中):

/session/viewhtml36b8729177dc/index.html?viewer_pane=1&capabilities=1&host=http%3A%2F%... 未找到

使用的代码

library(tidyverse)
library(scales)
library(plotly)

recent_grads <- read_csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/college-majors/recent-grads.csv")

majors_processed <- recent_grads %>%
  arrange(desc(Median)) %>%
  mutate(Major = str_to_title(Major),
         Major = fct_reorder(Major, Median))

g <- majors_processed %>%
  mutate(Major_category = fct_lump(Major_category, 4)) %>%
  ggplot(aes(ShareWomen, Median, color = Major_category, size = Sample_size, label = Major)) +
  geom_point() +
  geom_smooth(aes(group = 1), method = "lm") +
  scale_x_continuous(labels = percent_format()) +
  scale_y_continuous(labels = dollar_format()) +
  expand_limits(y = 0)

ggplotly(g)
> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
plotly_4.9.2.1
RStudio 1.3.1073

对此的任何支持将不胜感激。

标签: rggplotly

解决方案


推荐阅读