使用statebins包时colorbrewer调色板的反转顺序

使用statebins包时colorbrewer调色板的反转顺序,r,ggplot2,palette,spectral,colorbrewer,R,Ggplot2,Palette,Spectral,Colorbrewer,我正在使用statebins软件包绘制我们50个州的能源消耗图。尽管colorbrewer的spectrum调色板在绘图上看起来不错: 这与我所希望的完全相反。如何反转光谱颜色的顺序。在ggplot中,我使用brewerpal的相反顺序: statebins( dataset ,state_col= "state", value_col="value", brewer_pal = "Spectral",) 但是当我以另一种方式使用Spectral时,就像在第一个代码块中一样,我不

我正在使用
statebins
软件包绘制我们50个州的能源消耗图。尽管colorbrewer的
spectrum
调色板在绘图上看起来不错:

这与我所希望的完全相反。如何反转光谱颜色的顺序。在ggplot中,我使用brewerpal的相反顺序:

statebins( dataset ,state_col= "state", value_col="value",
      brewer_pal = "Spectral",) 
但是当我以另一种方式使用
Spectral
时,就像在第一个代码块中一样,我不能使用相反的顺序

有关Statebins包的详细信息:


我在这里使用的函数是statebins(它为美国各州创建一个新的基于ggplot的“statebin”图表,离散比例)

这是
statebins()
的源代码行,它在
ggplot
层中设置调色板:

scale_fill_gradientn(colours = rev(brewer.pal(20,'Spectral')))
gg
gg <- gg + scale_fill_brewer(palette = brewer_pal, name = legend_title)