Execute R Script - characters not displaying on saved image

David Alexander 1 Reputation point
2022-02-03T14:55:46.447+00:00

Updated this question with new information:

Using Azure ML Studio & Execute R Script to run some existing models. I need to generate outputs with saved plots which I am doing with the openxlsx package and saving the outputs to some azure cloud storage. This part all works well. The problem is that the plots do not have characters displayed correctly, instead they are "squares"

I have recreated the problem with some repeatable code using the data in ggplot2. This is the relevant code snippet that I am running in an "azureml_main" function. This example I actually copied from another azure help page to keep things simple and compatible as possible : https://gallery.azure.ai/Experiment/Tutorial-Base-R-Graphics-in-AzureML-2

  imageName <- "testplot.png"  
  png(imageName)  
  plot(price ~ carat, data = diamonds, main = "Price vs Carat")  
  dev.off()  
  wb <- createWorkbook()  
  addWorksheet(wb, "testplotsheet", gridLines = TRUE)  
  insertImage(wb, "testplotsheet", imageName)  
  saveWorkbook(wb, file = xlName, overwrite = TRUE)  

On retrieving the saved excel workbook, this is what the image looks like

171081-savedpng-nochars.jpg

The problem is to get characters to display correctly. The same problem occurs in tiff, jpg svg formats. But pdf displays fonts! On further investigation I am wondering if there are actually any system fonts installed on this compute cluster machine because the folders /usr/lib/share/fonts & /usr/share/fonts do not exist

Can anyone at microsoft check & confirm this (seems a bit of an oversight?) or advise where the fonts are installed for this "Execute R script" machine

Here are some data from the azureml instance sessionInfo

R version 3.5.1 (2018-07-02)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS: /azureml-envs/azureml_6ff64eff0a652bbe0bb1d84fc0884554/lib/R/lib/libRblas.so
LAPACK: /azureml-envs/azureml_6ff64eff0a652bbe0bb1d84fc0884554/lib/R/lib/libRlapack.so

locale:
1 LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
[4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
[7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C

attached base packages:
1 stats graphics grDevices utils datasets methods base

other attached packages:
1 httr_1.4.1 RODBC_1.3-16 tibble_3.0.1 tidyr_1.0.2
[5] stringr_1.4.0 data.table_1.12.8 azuremlsdk_1.10.0 openxlsx_4.2.5
[9] dplyr_0.8.5 jsonlite_1.6.1 reticulate_1.12

loaded via a namespace (and not attached):
1 Rcpp_1.0.8 magrittr_1.5 tidyselect_1.0.0 lattice_0.20-41
[5] R6_2.4.1 rlang_1.0.1 tools_3.5.1 grid_3.5.1
[9] ellipsis_0.3.0 assertthat_0.2.1 lifecycle_0.2.0 crayon_1.3.4
[13] Matrix_1.2-18 zip_2.2.0 purrr_0.3.4 vctrs_0.2.4
[17] glue_1.4.0 stringi_1.4.3 compiler_3.5.1 pillar_1.4.3
[21] pkgconfig_2.0.3

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,332 questions
{count} votes

2 answers

Sort by: Most helpful
  1. David Alexander 1 Reputation point
    2022-02-07T08:12:30.023+00:00

    @YutongTie-MSFT apologies for the tag, but no other responders yet. Any further suggestions or insight into why this problem is occurring? I have done extensive research into this and it must be something to do with the available encoding/fonts on the Ubuntu setup on ML Studio & what the code is attempting to use in the png encoding. Your suggestion made a lot of sense, but didn't seem to change the environment at all? Any idea why? It's also incredibly difficult to troubleshoot because in this black-box Azure ML studio I do not have access to a console to run code segments


  2. David Alexander 1 Reputation point
    2022-02-08T10:56:36.127+00:00

    update : there are no fonts installed in R or seemingly on the container/image which is launched by "Execute R script". The system contains no fonts folder or /etc/fonts/fonts.conf file, which is what it should be for ubuntu. R installation does not have "sysfonts" library and it can't be installed due to a missing file "zlib". if sysfonts could be installed I could use showtext, or possibly resolve the issue

    I've spent a week on this trying to get execute r task to save an image with characters, but it doesn't seem possible

    Update : this image/compile needs to be updated, the R version is from 2018, and missing fonts. FYI, this refers to the "cluster" version"

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.