Index of every page on this site: llms.txt
All skills
victory-hugo avatar

/code-visualization-palette

@0b19307
Run it yourself

精美的可视化调色盘,在数据可视化中使用;若使用tidyplots包,则不必使用本技能。

  • 4 files
  • 13 KB
  • Updated 3 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/victory-hugo/s2-agent-skill/code-visualization-palette

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesr-visualization-examples.md

≈475 tokens on demand. Your agent reads this file only when SKILL.md points to it.

R 可视化示例

离散色板辅助函数

discrete_1 <- c("#0072b2", "#56b4e9", "#009e73", "#f0e442", "#e69f00", "#d55e00")
discrete_2 <- c("#8ecae6", "#219ebc", "#023047", "#ffb703", "#fb8500")

categorical_palette <- function(n) {
  if (n <= 6) {
    return(discrete_1[seq_len(n)])
  }
  if (n <= 11) {
    return(c(discrete_1, discrete_2[seq_len(n - 6)]))
  }
  warning("More than 11 categories reduce color discrimination.")
  grDevices::colorRampPalette(c(discrete_1, discrete_2))(n)
}

ggplot2 分类图

library(ggplot2)

palette <- categorical_palette(length(unique(df$group)))

ggplot(df, aes(group, value, fill = group)) +
  geom_col() +
  scale_fill_manual(values = palette)

ggplot2 连续单色渐变

library(ggplot2)

sequential <- c(
  "#0b0405", "#30203e", "#3e4d93", "#366b9f", "#3488a6",
  "#36a4ab", "#49c1ad", "#60ceac", "#84d8b0", "#c4e9cf", "#def5e5"
)

ggplot(df, aes(x, y, fill = score)) +
  geom_tile() +
  scale_fill_gradientn(colours = sequential)

ggplot2 连续双色渐变

library(ggplot2)

diverging <- c(
  "#5b53a4", "#456fb1", "#368cbb", "#4fa8af", "#69c3a5", "#8ad0a4",
  "#addda3", "#c9e99d", "#e6f598", "#fefdbc", "#fef0a6", "#fdc877",
  "#f88f52", "#e55848", "#bc2349", "#a20643"
)

ggplot(df, aes(x, y, fill = log2fc)) +
  geom_tile() +
  scale_fill_gradientn(colours = diverging, values = scales::rescale(seq(-3, 3, length.out = length(diverging))))

ComplexHeatmap 示例

library(ComplexHeatmap)
library(circlize)

col_fun <- circlize::colorRamp2(
  c(min(matrix), median(matrix), max(matrix)),
  c("#0b0405", "#49c1ad", "#def5e5")
)

Heatmap(matrix, col = col_fun)

连续分箱取色

sample_evenly <- function(colors, n) {
  if (n <= 1) {
    return(colors[1])
  }
  idx <- round(seq(1, length(colors), length.out = n))
  colors[idx]
}

binned <- sample_evenly(sequential, 5)

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 0b19307. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 3 months ago

README badge

README badge for victory-hugo/s2-agent-skill/code-visualization-palette