X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=PrintRScript.py;h=1bb0af1ce65a7afab05373244caabced69725125;hp=7aa30d65eb868d5398e36f5f3b4de94918ad7224;hb=c5650ea708101e654d8851350494c0e9a712b6ed;hpb=0bb1e9556fdbb07e171b663ffcea149692a8a49f diff --git a/PrintRScript.py b/PrintRScript.py index 7aa30d6..1bb0af1 100644 --- a/PrintRScript.py +++ b/PrintRScript.py @@ -51,6 +51,8 @@ class PrintRScript : class chdtxt(PrintRScript) : pass +def Rcolor(color) : + return str(color).replace(')', ', max=255)') class Alceste2(PrintRScript) : def doscript(self) : @@ -908,3 +910,21 @@ class PrintSimiScript(PrintRScript) : self.add(txt) self.write() +class WordCloudRScript(PrintRScript) : + def make_script(self) : + self.sources([self.analyse.parent.RscriptsPath['Rgraph']]) + self.packages(['wordcloud']) + bg_col = Rcolor(self.parametres['col_bg']) + txt_col = Rcolor(self.parametres['col_text']) + txt = """ + act <- read.csv2("%s", header = FALSE, row.names=1, sep='\t') + selected.col <- read.table("%s") + toprint <- act[selected.col[,1] + 1,] + open_file_graph("%s", width = %i, height = %i) + par(bg=rgb%s) + wordcloud(row.names(toprint), toprint[,1], scale=c(%f,%f), random.order=FALSE, colors=rgb%s) + dev.off() + """ % (ffr(self.analyse.pathout['actives_eff.csv']), ffr(self.analyse.pathout['selected.csv']), + ffr(self.parametres['graphout']), self.parametres['width'], self.parametres['height'], bg_col, self.parametres['maxcex'], self.parametres['mincex'], txt_col) + self.add(txt) + self.write()