简体   繁体   中英

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. 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.

I have filtered the rows of the dataset by "STATE" and so the "Process_Time" has breaks in it.

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")

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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