calendR - 显示同一天冲突事件的选项?

问题描述 投票:0回答:1

使用 CalendR 绘制船只的捕鱼日。 1 月 2 日星期二,两艘船共享钓鱼日期,但是当天Marlin 的颜色为绿色,您无法看到Fish Tales 在同一天钓鱼。

有没有办法可视化两种色调/颜色,例如将一天水平或垂直分成两半?

我想也许可以使用一个符号来指示同一天的多次旅行,并在图中的某处对其进行注释,但这将是最不受欢迎的选择。

加载包、创建事件和绘图日历:

## load packages
library(tidyverse)
library(calendR)
library(viridis) 
library(scales)

## events
events <- rep(NA, 366) ## 2024 is a leap year

## corresponding events
events[c(3, 22, 45, 63, 100, 140, 195, 234, 300)] <- "Big Catch" ## boat 1
events[c(2, 36, 59, 123, 167, 210, 289, 340)] <- "Fish Tales" ## boat 2
events[c(2, 25, 80, 155, 255, 297, 339)] <- "Marlin" ## boat 3
events[c(1, 89, 92, 142, 143, 239, 360, 361)] <- "Holiday" ## holidays

## holiday to come last
desired_order <- factor(c(levels = c("Big Catch", "Fish Tales", "Marlin", "Holiday"))) 

## select desired order and colourway
show_col(viridis_pal()(5)) ## colour palette = viridis
print(viridis_pal()(5)) 

## order colours
ordered_colours <- c("#3b528bff", "#21908cff", "#5dc863ff", "lightgray")[order(desired_order)]

## plot
calendR(year = 2024, start = "M",
        special.days = events,
        special.col = c(ordered_colours), 
        lty = 1, bg.col = "white",    
        subtitle.col = 1,
        weeknames = c("M", "T", "W", "T", "F", "S", "S"),
        day.size = 3.5,
        orientation = "l",
        legend.pos = "bottom"
)

r events calendar days customising
1个回答
0
投票

设置其他键/颜色的组合是否有效? 你可以做这样的事情。


b2 <- c(2, 36, 59, 123, 167, 210, 289, 340)
b3 <- c(2, 25, 80, 155, 255, 297, 339)

b2_3 <- intersect(b2, b3)


boat2 <- setdiff(b2, b2_3)
boat3 <- setdiff(b3, b2_3)

events[boat2] <- "Fish Tales" 
events[boat3] <- "Marlin"
events[b2_3] <- "Fish Tales / Marlin"
© www.soinside.com 2019 - 2024. All rights reserved.