简体   繁体   English

ggthemes scale_colour_solarized("blue") 在应用于绘图时给出“[[: subscript out of bounds”中的错误

[英]ggthemes scale_colour_solarized("blue") gives "Error in [[: subscript out of bounds" when applied to a plot

plot <-
    ggplot(tot_costs,
           aes(period, total_cost, colour = team, group = team)) +
    geom_point() +
    geom_line() +
    ylab("") +
    xlab("Year") +
    # Commented working code theme_minimal() +
    theme_solarized(light = FALSE, base_size = 16) + scale_colour_solarized("blue") +
    theme(axis.text.x = element_text(angle = 45),
          legend.title = element_blank())

When I replace the theme_solarized by theme_minimal, everything is working, but when I try to apply theme_solarized/scale_colour to the plot, I get a "Subscript out of bounds error".当我用 theme_minimal 替换 theme_solarized 时,一切正常,但是当我尝试将 theme_solarized/scale_colour 应用于绘图时,我得到一个“下标越界错误”。 I wonder if it's related to the color palette, maybe there are too many "teams" for the colors available.我想知道它是否与调色板有关,也许有太多可用颜色的“团队”。 However, it's the solarized theme is working fine with other plots with the same teams然而,它的日晒主题与同一团队的其他情节配合得很好

In the documentation for scale_color_solarized() it says to:scale_color_solarized()的文档中,它说:

See solarized_pal() for details.有关详细信息,请参阅 solarized_pa​​l()。

Looking into ?ggthemes::solarized_pal , it says: ?ggthemes::solarized_pal ,它说:

This palette supports up to seven values.此调色板最多支持七个值。

I guess in this case your easiest choice is to use a different color scale.我想在这种情况下,您最简单的选择是使用不同的色标。

By the way, distinguishing more than around seven colours can prove difficult if they are close togheter in a plot, so think about giving an additional aesthetic to your team variable (eg shape).顺便说一句,如果它们在一个情节中非常接近,那么区分大约七种以上的颜色可能会很困难,因此请考虑为您的团队变量(例如形状)赋予额外的美感。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM