openair
openair copied to clipboard
font issue
I am trying to run R script on 2 machines - both have opensuse. On machine1 the script works fine (attached - issue.png ) where as on second machine, it seems the plotting mechanism is unable to detect font (attached - ok.png). Here is the script which i am using -
cat /home/$USER/jobs/plot.R
#!/home/apps/SiteSoftwares/gnu/R.3.4.3/bin/R
library(openair)
load("NDL2010-2017at500m.RData")
traj$Year <- as.character(traj$date,format="%Y")
png(file="testNormal_inter.png",width = 5*300, height = 3*300, res=50)
#png(file="test.png",width = 5*300, height = 3*300, res=50)
trajLevel(traj,method="hexbin",col="jet",xbin=40,parameters=NULL,orientation=c(90,0,0),projection="mercator",type="Year",grid.col = "transparent",map.fill=FALSE,map.cols = "transparent",map.alpha = 0.2,layout=c(4,2),par.settings=list(fontsize=list(text=50)))
dev.off()
Is there a way to test what library / files are missing on machine2 ? Please let me know if i can provide more information on this issue.
Package extrafont may be helpful. https://blog.revolutionanalytics.com/2012/09/how-to-use-your-favorite-fonts-in-r-charts.html
thanks @jobonaf , i tried another example ` getwd() library(extrafont) loadfonts() set.seed(1) x <- 1:100 y <- 0.029*x + rnorm(100)
pdf("sample.pdf", 7, 5) plot(x, y, pch=19, col=rgb(0.5, 0.5, 0.5, 0.5), cex=1.5) abline(lm(y ~ x)) dev.off()
png("sample.png", 490, 350) options(bitmapType='cairo') plot(x, y, pch=19, col=rgb(0.5, 0.5, 0.5, 0.5), cex=1.5) abline(lm(y ~ x)) dev.off()
bmp("sample.bmp", 490, 350) plot(x, y, pch=19, col=rgb(0.5, 0.5, 0.5, 0.5), cex=1.5) abline(lm(y ~ x)) dev.off()
tiff("sample.tiff", 490, 350) plot(x, y, pch=19, col=rgb(0.5, 0.5, 0.5, 0.5), cex=1.5) abline(lm(y ~ x)) dev.off()
jpeg("sample.jpg", 490, 350) plot(x, y, pch=19, col=rgb(0.5, 0.5, 0.5, 0.5), cex=1.5) mtext("Magic function", side=3) abline(lm(y ~ x)) dev.off() ` pdf plotting is good, rest other image functions fail to produce desired plot. though this is not an issue with openair, any suggestion will be very useful.
font_import()
loadfonts() # if OS is Linux
loadfonts(device ="win") # if OS is Windows
fonts() # to list available font families
png("test.png")
plot(x, family ="Impact") # if available
dev.off()
Another answer which may be useful is found here: https://github.com/davidcarslaw/openair/issues/100