【问题标题】:hillshade issue with rayshader ggplotrayshader ggplot 的山体阴影问题
【发布时间】:2022-11-22 04:22:52
【问题描述】:

根据帖子中提供的代码和数据(从rayshader教程网站获得),我得到如下所示的错误。

可能是什么原因造成的,如何解决?

错误:

Error in hillshade[, , 1] * scales::rescale(shadowmap, c(max_darken, 1)) : 
  non-conformable arrays

代码:

library(tidyverse)
library(reshape2)
library(viridis)
library(rayshader)

measles = read_csv("https://tylermw.com/data/measles_country_2011_2019.csv")
melt_measles = reshape2::melt(measles, id.vars = c("Year", "Country", "Region", "ISO3"))
melt_measles$Month = melt_measles$variable
melt_measles$cases = melt_measles$value

# Plot
melt_measles %>% 
  group_by(Year, Month) %>%
  summarize(totalcases = sum(cases,na.rm = TRUE)) %>% 
  mutate(totalcases = ifelse(Year == 2019 & !(Month %in% c("January","February","March")), NA, totalcases)) %>%
  ggplot() + 
  geom_tile(aes(x=Year, y=Month, fill=totalcases,color=totalcases),size=1,color="black") + 
  scale_x_continuous("Year", expand=c(0,0), breaks = seq(2011,2019,1)) +
  scale_y_discrete("Month", expand=c(0,0)) +
  scale_fill_viridis("Total\nCases") +
  ggtitle("Reported Worldwide Measles Cases") +
  labs(caption = "Data Source: WHO") +
  theme(axis.text = element_text(size = 12),
        title = element_text(size = 12,face="bold"),
        panel.border= element_rect(size=2,color="black",fill=NA)) -> 
measles_gg

plot_gg(measles_gg, multicore = TRUE, width = 6, height = 5.5, scale = 300, 
background = "#afceff",shadowcolor = "#3a4f70")

【问题讨论】:

  • 这是一个已知问题 <github.com/tylermorganwall/rayshader/issues/176> 我猜你已经做了一些更新?!
  • devtools::install_github("tylermorganwall/rayshader")修复了它:)
  • 确切地。我花了很长时间才安装它。干杯!

标签: r ggplot2 rayshader


【解决方案1】:

这是一个已知问题 <github.com/tylermorganwall/rayshader/issues/176>

我用remotes::install_github("tylermorganwall/rayshader")测试过

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-08
    • 2014-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-16
    相关资源
    最近更新 更多