juba / rainette

R implementation of the Reinert text clustering method
https://juba.github.io/rainette/
53 stars 7 forks source link

Save plots produced by rainette2_plot to disk #17

Closed gabrielparriaux closed 2 years ago

gabrielparriaux commented 2 years ago

Hello,

I wanted to save the image of the plot produced by rainette2_plot to disk using code.

I tried to use ggsave after having produced the plot with rainette2_plot, which quite works, but only the image of the last cluster gets saved.

Is there an easy way to save the whole plot to the disk?

Thanks a lot for your help,

Gabriel

juba commented 2 years ago

Something like the following should work.

g <- rainette_plot(res, dtm, k = 5)
ggsave("out.png", g)
gabrielparriaux commented 2 years ago

Great, thanks a lot, it is working!

When I try to save to PDF, I get these alerts in console:

Messages d'avis :
1: Dans grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y,  :
  erreur de conversion de 'fleur' dans 'mbcsToSbcs' : le point est substitué pour <ef>
2: Dans grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y,  :
  erreur de conversion de 'fleur' dans 'mbcsToSbcs' : le point est substitué pour <ac>
3: Dans grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y,  :
  erreur de conversion de 'fleur' dans 'mbcsToSbcs' : le point est substitué pour <82>
4: Dans grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y,  :
  erreur de conversion de 'fleur' dans 'mbcsToSbcs' : le point est substitué pour <ef>
5: Dans grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y,  :
  erreur de conversion de 'fleur' dans 'mbcsToSbcs' : le point est substitué pour <ac>
6: Dans grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y,  :
  erreur de conversion de 'fleur' dans 'mbcsToSbcs' : le point est substitué pour <82>

But the PDF file is still produced correctly.

Should I be preoccupied by that? Anyway, that works, so thanks again!

Gabriel

juba commented 2 years ago

The issue is not related to rainette, it is linked to the fact that in 'fleur' the "fl" is a special ligature character, and when grid tries to convert it for PDF export, it fails. The result should be that the "fl" character may be missing in your export. One workaround may be to convert the ligature "fl" to the two characters sequence "fl".

gabrielparriaux commented 2 years ago

Ah ok, thank you! Working with a part of my corpus coming from PDF documents taken on the internet and converted to txt, I have had quite a lot of problems with these conversions… some characters were not properly converted and also I didn’t think of those ligatures! Now I see…

I will replace the ligatures with the two character sequence and redo my analysis!