R 表示为比例\填充\渐变n ggplot2,恒定渐变

R 表示为比例\填充\渐变n ggplot2,恒定渐变,r,ggplot2,scale,gradient,polar-coordinates,R,Ggplot2,Scale,Gradient,Polar Coordinates,我有以下代码使用ggplot2创建极坐标图,但当我使用其他数据运行相同代码时,无法保持相同的比例颜色值 有3个不同的变量可以表示,一个是方向: plot.new() ggplot(NS_Enero, aes(x = wd, y = ws, fill = manganese, size = manganese)) + coord_polar() + geom_point(shape = 21, show.legend = TRUE) + scale_size(range = c(3,1

我有以下代码使用ggplot2创建极坐标图,但当我使用其他数据运行相同代码时,无法保持相同的比例颜色值

有3个不同的变量可以表示,一个是方向:

plot.new()
ggplot(NS_Enero, aes(x = wd, y = ws, fill = manganese, size = manganese)) +
  coord_polar() +
  geom_point(shape = 21, show.legend = TRUE) +
  scale_size(range = c(3,12),
             labels = c("50", "150", "450", "1350", "4050"),
             breaks = c(50, 150, 450, 1350, 4050),
             name = expression(paste(PM[10]~bound~Mn~(ng/m^3)))) +
  scale_fill_gradientn(colours = c("darkblue","blue", "yellow", "orange", "red"),
                       space = "Lab",
                       guide = "legend",
                       values = rescale(c(0, 150, 450, 1350, 4401),
                                        from = c(0, 4401)),
                       labels = c("50", "150", "450", "1350", "4050"),
                       breaks = c(50, 150, 450, 1350, 4050),
                       name = expression(paste(PM[10]~bound~Mn~(ng/m^3)))) +
  scale_x_continuous(limits= c(0,360),
                     breaks= c(0, 90, 180, 270), 
                     labels = c("N","E","S","W"),
                     name = "") +
  scale_y_continuous(name = "Distance (m)",
                     position = "left") +
  theme_linedraw() +
  theme(axis.text.x = element_text(size = 12),
        axis.text.y = element_text(size = 8)) +
  ggtitle("                 NS_Enero")
当我尝试用不同的数据运行相同的代码时,输出图会改变比例的值,我尝试了许多在其他问题中找到的技巧,但我无法解决比例表示的问题。我认为问题在于比例填充梯度的值

产出1:

输出2个不同的数据:

最终的结果是可以的,但我希望缩放范围大小和颜色的值在我使用不同数据范围运行的所有绘图中保持不变。0到4050之间的值的大小和颜色值相同

非常感谢您的帮助。

最后,添加限制很有效

这是最终代码:

#Tamaño y color
plot.new()
ggplot(NS_Junio, aes(x = wd, y = ws, fill = manganese, size = manganese)) +
  coord_polar() +
  geom_point(shape = 21, show.legend = TRUE) +
  scale_size(range = c(3,12),
             labels = c("50", "150", "450", "1350", "4050"),
             breaks = c(50, 150, 450, 1350, 4050),
             limits = c(1,4050),
             name = expression(paste(PM[10]~bound~Mn~(ng/m^3)))) +
  scale_fill_gradientn(colours = c("darkblue","blue", "yellow", "orange", "red"),
                       space = "Lab",
                       guide = "legend",
                       values = rescale(c(0, 150, 450, 1350, 4401),
                                        from = c(0, 4401)),
                       labels = c("50", "150", "450", "1350", "4050"),
                       breaks = c(50, 150, 450, 1350, 4050),
                       limits = c(1,4050),
                       name = expression(paste(PM[10]~bound~Mn~(ng/m^3)))) +
  scale_x_continuous(limits= c(0,360),
                     breaks= c(0, 90, 180, 270), 
                     labels = c("N","E","S","W"),
                     name = "") +
  scale_y_continuous(name = "Distance (m)",
                     position = "left") +
  theme_linedraw() +
  theme(axis.text.x = element_text(size = 12),
        axis.text.y = element_text(size = 8)) +
  ggtitle("                 NS_Enero")

也许可以在比例填充梯度中指定限制?哦,天哪,这很简单,但很有效,非常感谢你的帮助。