简体   繁体   English

图例中缺少ggplot颜色栏

[英]ggplot color bar missing in legend

I am new to this forum, but i have found many answers searching through the threads. 我是这个论坛的新手,但是我在这些主题中找到了很多答案。 I am far from a programmer, but use R for creating custom graphs. 我离程序员还很远,但是使用R创建自定义图。 I have been climbing the learning curve, but hit a wall when trying to show 2 variables in a scatterplot, while desiring to show a third dimension Process_Time. 我一直在学习曲线,但是在试图显示散点图中的2个变量而又想显示第3维Process_Time时遇到困难。

I have filtered the rows of the dataset by "STATE" and so the "Process_Time" has breaks in it. 我已按“ STATE”过滤了数据集的行,因此“ Process_Time”已中断。

A summary of the dataframe is below: 数据框的摘要如下:

'data.frame':   71896 obs. of  10 variables:
 $ key         : Factor w/ 6 levels "ATAB","CCNa",..: 1 1 1 1 1 1 1 1 1 1 
 $ Process_Time: num  4.32 4.33 4.35 4.37 4.38 ...
 $ CONC_PCT    : num  30.9 31 31 30.9 30.9 ...
 $ STATE       : Factor w/ 4 levels "Blind","Gravimetric",..: 2 2 2 2 2 2 2 
 $ NW          : num  1.15 1.14 1.14 1.14 1.13 ...
 $ SRW_SP      : num  106 105 105 106 105 ...
 $ FF          : num  2.45 2.46 2.46 2.45 2.45 ...
 $ MF          : num  15.5 15.5 15.5 15.4 15.4 ...
 $ Max_Mass    : num  1.72 1.72 1.72 1.72 1.72 ...
 $ NW_norm     : num  0.67 0.667 0.665 0.663 0.66 ...

The code is below: 代码如下:

FF_DATA <- subset(FF_Data, STATE=="Gravimetric")

FF_NW <- ggplot(FF_DATA,aes(NW_norm,FF)) + 
geom_point(aes(color = Process_Time ))+
facet_grid(key~.,scales = "free")+
scale_color_gradient()

在此处输入图片说明

Maybe the issue is rendering gradients. 也许问题在于渲染渐变。 Try this, see if it works on your machine 尝试一下,看看它是否在您的机器上运行

library(ggplot2)

ggplot(mtcars, aes(x = wt, y = disp)) + 
  geom_point(aes(color = mpg)) + 
  facet_grid(gear~.,scales = "free")+
  scale_color_gradient()

在此处输入图片说明

I saved with: ggsave("eg.png", type = "cairo") 我用以下ggsave("eg.png", type = "cairo")保存: ggsave("eg.png", type = "cairo")

It seems I have a rendering issue. 看来我有一个渲染问题。 I have read about this in a few other posts on the issue and have no idea where to start. 我已经在有关此问题的其他几篇文章中阅读了此内容,但不知道从哪里开始。

enter image description here 在此处输入图片说明

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

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