plotly / orca

Command line application for generating static images of interactive plotly charts
MIT License
294 stars 40 forks source link

R: Latin1 encoding errors when exporting with orca #224

Open mgf-unige opened 5 years ago

mgf-unige commented 5 years ago

Hi,

Thanks, I use the R plotly library.

Here is an example:

ex  <- data.frame(region = c("Pará", "Pará", "Pará", "Pará", "Pará", "Region2", "Region2", "Region2", "Region2", "Region2", "Region3", "Region3", "Region3", "Region3", "Region3"),
                  country = c("Brazil", "Brazil", "Brazil", "Brazil", "Brazil", "Country2", "Country2", "Country2", "Country2", "Country2", "Country3", "Country3", "Country3", "Country3", "Country3"),
                  var = c("VAR1", "VAR1", "VAR1", "VAR1", "VAR1", "VAR1", "VAR1", "VAR1", "VAR1", "VAR1", "VAR1", "VAR1", "VAR1", "VAR1", "VAR1"),
                  value = c(2,5,7,5,4,3,9,5,7,5,3,7,6,9,3))
p <- plot_ly(ex) %>%
  add_trace(x = ~region, y = ~value,
            color = ~country, fillcolor = ~country, opacity = 1.0,
            type = 'box', boxpoints = "all", jitter = 0.0,
            pointpos = 0, line = list(width = 1),
            marker = list(color = '#000000', opacity = .8, size = 2),
            orientation = "v", showlegend = T) %>%
  layout(xaxis = list(title = 'Region', tickangle = 270, zeroline = FALSE,
                      categoryorder = "array",
                      categoryarray = c(unique(ex$country))),
         yaxis = list(title = 'Value', zeroline = FALSE),
         boxmode = "group", boxgap = 0.05, boxgroupgap = 0.3,
         legend = list(bgcolor = 'transparent'))
p
plotly_IMAGE(p, width = 600, height = 400, format = "png", scale = 1, dpi = 600,
             out_file = paste0("D:/Ex01a.png"))
setwd(paste0("D:/"))
orca(p, file = paste0("Ex01b.png"),
     width = 600, height = 400, format = "png", scale = 1)

The plotly'IMAGE command results in: Ex01a

While the orca command results in (note the á in the Pará label): Ex01b

Diniodoc commented 5 years ago

Same problem with the EUR-Symbol €.

** just found out that there is no problem when using orca_serve() ==> export() instead of orca(). [Windows 10]

0navarro commented 4 years ago

Hi, I have a similar problem with the squared symbol ² and the degrees symbol °.

I have tried using orca_serve() (in Windows 7) as well but it does not work. Does anyone have any solution/workaround?

sylvaine31 commented 4 years ago

Hi, I have the same problem, did you solved it? I have no encoding problem with the deprecated plotly::export function, but I would prefer using orca...

mgf-unige commented 4 years ago

Hi, unfortunately not... I just replaced all the "special" characters with the same characters without the accents... I know it's not that great but I use this function in R to reformat the strings if it can help:

toPlain <- function(s) { old <- "èéêëùáôãçâ" new <- "eeeeuaoaca" s1 <- chartr(old, new, s)
}

sylvaine31 commented 4 years ago

OK thanks. I'm just suprised that there is just this thread about it...

sylvaine31 commented 4 years ago

Finally, I used the solution proposed by #0navarro with orca_serve and it resolved my problem.

mgf-unige commented 4 years ago

OK, I will try it as well!

fcasarramona commented 4 years ago

Still happens with version 1.2.1

guenterhack commented 4 years ago

Is there a fix or a workaround for this problem yet? It means that Orca is very hard to use in German, because it can't handle umlauts. I can export my graphs as SVG or PDF and edit every single line, but I can't build automated workflows this way. Any help would be greatly appreciated.

bixiou commented 3 years ago

I can't use the orca_serve solution because orca_serve() requires admin rights, and 1. I don't want to be prompted 100 times, 2. in any case, as I've put orca within a function, I am not prompted for admin rights in this case, it just returns an error. As anyone found a fix for orca()? PS : I don't think it's only related to latin1, because my encoding is UTF-8. I had no problem on Ubuntu, the problem only appears on Windows 10.