grDevice

colors()

图片alt

图片alt

pal <- colorRamp(c("red","blue"))
pal(seq(0,1,len=10))
        [,1] [,2]      [,3]
 [1,] 255.00000    0   0.00000
 [2,] 226.66667    0  28.33333
 [3,] 198.33333    0  56.66667
 [4,] 170.00000    0  85.00000
 [5,] 141.66667    0 113.33333
 [6,] 113.33333    0 141.66667
 [7,]  85.00000    0 170.00000
 [8,]  56.66667    0 198.33333
 [9,]  28.33333    0 226.66667
[10,]   0.00000    0 255.00000
pal <- colorRampPalette(c("red","blue"))
pal(10)
[1] "#FF0000" "#E2001C" "#C60038" "#AA0055" "#8D0071" "#71008D" "#5500AA" "#3800C6" "#1C00E2" "#0000FF"

图形设备

基本函数

Web graphics device

install.packages("httpgd")
hgd()
x = seq(0, 3 * pi, by = 0.1)
plot(x, sin(x), type = "l")
dev.off()

图像导出

png(file="waterfall.png",width = 12,height =8,units = "in",res = 300)
waterfall(waterfall_infput,fileType="Custom",variant_class_order = variant_class_order, maxGenes=15,mainPalette=rev(col2))
dev.off()
png(file="waterfall.png",width = 4000,height =3000,res = 300)
waterfall(waterfall_infput,fileType="Custom",variant_class_order = variant_class_order, maxGenes=15,mainPalette=rev(col2))
dev.off()

当units=“px”时,更改res像素大小,width和height也有增大相同倍数

常用导出图片参数

ggsave(res,filename=“file.png”,units="in")
png(filename = "file.png", width = 7, height = 7, res = 300, units = "in")

参考