Alpha level affecting the appearance in pdf format in comparison with png-graphics in R

I am trying to understand why colors look boring when I specify the alpha level in rgb and save the graph as pdf (for color transparency less than 1). This does not happen when saving as png .

Consider these 3 check digits:

 # Figure 1 # pdf with alpha specified in rgb # blues are dull and muted relative to colors in plot window pdf('test1.pdf', height = 4, width = 4) plot(1,1, type = 'n') rect(0, 0, 1, 2, col = rgb(red = 0, green = 0, blue = 1, alpha = 0.1)) abline(v = 1.3, col = 'blue', lwd = 5) dev.off() 

Figure 1

 # Figure 2 # png with alpha specified in rgb # colors are same as plot window png('test2.png', height = 288, width = 288) plot(1, 1, type = 'n') rect(0, 0, 1, 2, col = rgb(red = 0, green = 0, blue = 1, alpha = 0.1))) abline(v = 1.3, col = 'blue', lwd = 5) dev.off() 

Figure 2

 # Figure 3 # pdf, alpha not specified in rgb # colors are same as plot window pdf('test3.pdf', height = 4, width = 4) plot(1,1, type = 'n') rect(0, 0, 1, 2, col = rgb(red = 0, green = 0, blue = 1)) abline(v = 1.3, col = 'blue', lwd = 5) dev.off() 

So, how can I use transparent colors while preserving the overall color scheme, how does it appear in the console / graph window, also when using pdf ?

EDIT: I am using Windows 7 and just realized that this does not seem to be a problem in Windows 8 or 10. However, I duplicated it on Mac OS 10.7.5 (Lion). I also know that I had this problem with any version of R that I used in 2013, as well as with this more current version.

 > sessionInfo() R version 3.3.1 (2016-06-21) Platform: i386-w64-mingw32/i386 (32-bit) Running under: Windows 7 (build 7601) Service Pack 1 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] reshape2_1.4.1 abind_1.4-5 CTSim_0.1.7 loaded via a namespace (and not attached): [1] Rcpp_0.12.5 raster_2.5-8 magrittr_1.5 MASS_7.3-45 splines_3.3.1 fdrtool_1.2.15 [7] lattice_0.20-33 FNN_1.1 quadprog_1.5-5 subplex_1.1-6 stringr_1.0.0 plyr_1.8.4 [13] tools_3.3.1 xts_0.9-7 GUILDS_1.2.1 parallel_3.3.1 grid_3.3.1 gstat_1.1-3 [19] poilog_0.4 poweRlaw_0.60.3 intervals_0.15.1 numDeriv_2014.2-1 sads_0.3.1 bbmle_1.0.18 [25] VGAM_1.0-2 sp_1.2-3 stringi_1.1.1 pracma_1.9.3 stats4_3.3.1 spacetime_1.1-5 [31] zoo_1.7-13 
+5
source share

Source: https://habr.com/ru/post/1263062/


All Articles