Ggsave () in ggplot for python not saving

I imported ggplot in python and run the following script with the hope that ggsave () will actually save my plot somewhere, however it does not seem to write anything about the .png file for use later, The plot returns when I return it as p in to my interpreter, but I need to manually save it.

import ggplot

#d as some pandas dataframe

k = [2,3,4,5]

for i in k:
    p = ggplot(d, aes(x='x', y='y', color='cluster'+str(i))) + geom_point(size=75) + ggtitle("Cluster Result: "+str(i))
    file_name = "Clusters_"+str(i)+'.png'  
    #this is not saving to any directory  
    ggsave(p,file=file_name)

This is the result in the interpreter ... but not a single file is saved in any directory.

Saving 11.0 x 8.0 in image.
Saving 11.0 x 8.0 in image.
Saving 11.0 x 8.0 in image.
Saving 11.0 x 8.0 in image.
Saving 11.0 x 8.0 in image.
Saving 11.0 x 8.0 in image.
+4
source share
2 answers

, , , . , Python. os.getcwd(), , . , ggsave.

ggsave(plot = p, filename = file_name, path = "C:\Documents\Graphs")

, User3926962 ggsave, , , p - . , , - , ggsave , , :

ggsave(p, filename = file_name)

:

TypeError: ggsave() 'filename'

, :

ggsave(plot = p, filename = file_name)

:

ggsave(filename = None, plot = None, device = None, format = None,
               path = None, scale = 1, width = None, height = None, units = "in",
               dpi = 300, limitsize=True, **kwargs)

+3

ggsave(p,file_name)
0

Source: https://habr.com/ru/post/1618917/


All Articles