【问题标题】:Plotly: How to set different colors for x-axis labels using R?Plotly:如何使用 R 为 x 轴标签设置不同的颜色?
【发布时间】:2019-12-16 11:05:09
【问题描述】:

我想为 x 轴上的日期标签设置不同的颜色,以便每个月都有不同的颜色。 就像下面的例子。我不知道这样的话题是否已经存在,但我在任何地方都找不到解决方案。

library(plotly)
today <- Sys.Date()
tm <- seq(0, 100, by = 1)
x <- today + tm
y <- rnorm(length(x))
plot_ly(x = ~x, y = ~y, type = 'scatter', mode = 'lines')  %>%
  layout(
      xaxis = list(
      type = 'date',
      tickformat = "%d %b %Y"
    ))

【问题讨论】:

  • 我的建议对你有什么效果?

标签: r dataframe plot plotly


【解决方案1】:

主题已经exists。您想要做的是可能的,但有点复杂,因为刻度标签的颜色与轴相关联,而不是刻度本身。目前最好的方法是add extra axes

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-06
    • 2021-04-18
    • 1970-01-01
    • 2014-07-05
    • 2020-07-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多