Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF file generated by pdf() does not export colors correctly #526

Open
LuisBoto opened this issue May 28, 2021 · 0 comments
Open

PDF file generated by pdf() does not export colors correctly #526

LuisBoto opened this issue May 28, 2021 · 0 comments

Comments

@LuisBoto
Copy link

LuisBoto commented May 28, 2021

The following code plots several data arrays in a simple plot()/lines() graph, with individual hexadecimal colors for each line:

pdf('plotFullSeiscientos.pdf')
plotFullSeiscientosDevice<-dev.cur()
png('plotFullSeiscientos.png')
dev.control('enable')
plot(timeInMSec11,bestFitness12, xlab="Time ms", ylab="Fitness", type='l', ylim=c(0.0000147055,0.0000375371), col='#0EB3AE')
lines(timeInMSec11, bestFitness22, col='#F491F8')
lines(timeInMSec11, bestFitness32, col='#B37E9F')
lines(timeInMSec11, bestFitness42, col='#604B6F')
lines(timeInMSec11, bestFitness52, col='#B4E33F')
lines(timeInMSec11, bestFitness62, col='#0D27DC')
lines(timeInMSec11, bestFitness72, col='#CE5214')
lines(timeInMSec11, bestFitness82, col='#20AE5D')
legend(x='topleft',legend=c('bestFitness 100 00', 'bestFitness 500 00', 'bestFitness 100 01', 'bestFitness 500 01', 'bestFitness 100 10', 'bestFitness 500 10', 'bestFitness 100 11', 'bestFitness 500 11'), fill=c('#0EB3AE', '#F491F8', '#B37E9F', '#604B6F', '#B4E33F', '#0D27DC', '#CE5214', '#20AE5D'))
dev.copy(which=plotFullSeiscientosDevice)
dev.off()
dev.off()

It also creates both a PNG and PDF files with said generated plot, from which the PNG appears to have correct colors:
imagen

However, the PDF file doesn't show any of these hexadecimal colors:
imagen

Some basic text-coded colors seem to appear just fine on pdf files (such as "red", "blue", "purple", etc.) however this is not the case for all of them either. Running the exact same script on RStudio outputs correct colors on the PDF file, and changing the pdf() function parameter 'colormodel' still produces similar problems. Tested on both 3.5-beta43 and latest RELEASE at the moment of writing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant