Error with stat='identity' in geom_bar
elvis-sik opened this issue · 2 comments
elvis-sik commented
A minimal example is
import pygg
import pandas as pd
data = pd.DataFrame({'x': range(10), 'y': range(10, 20)})
p = pygg.ggplot(data, pygg.aes(x='x', y='y'))
g = pygg.geom_bar(stat='identity')
pygg.ggsave('file.png', p + g, data=None)
The traceback says
ValueError: ggplot2 bridge failed for program: library(ggplot2)
data = read.csv("/tmp/tmpICcyg2",sep=",")
p = ggplot(data,aes(x=x,y=y)) + geom_bar(stat=identity)
ggsave("file.png",p,height=8,scale=1,width=10). Check for an error
sirrice commented
due to how strings are translated into R the following python statement:
pygg.geom_bar(stat='identity')
is translated into the following incorrect R script
geom_bar(stat=identity)
The way to get around this is to wrap the python script with pygg's esc()
:
pygg.geom_bar(stat=esc('identity'))
or to do it manually:
pygg.geom_bar(stat="'identity'")
elvis-sik commented
Thanks for your patience, now I see it has been documented since long before I opened this issue.