Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organising your output #81

Closed
jamesthomson opened this issue Aug 17, 2014 · 2 comments
Closed

Organising your output #81

jamesthomson opened this issue Aug 17, 2014 · 2 comments

Comments

@jamesthomson
Copy link

Hey plotly gang, I've just been trying out your product using the R API. It seems pretty useful. This isn't an issue as such, I was just looking for some help.

I've seen once you have produced your graph you can go to your workspace rename it to something more useful and pop it in a folder. Is there any way of doing this via your code in R? Otherwise i could see my workspace becoming a real mess very quickly.

I found something in the user guide i thought might help but it wouldn't run. Maybe i'm using it incorrectly or perhaps it doesn't do what i thought it would do at all. Any help would be appreciated.

#initialize acccess to the API
py <- plotly()
#create plot
box<-ggplot(iris, aes(factor(Species), Petal.Width)) + geom_boxplot()
#push your plot through the API
p2 <- py$ggplotly(box)
#how do you name and organise stuff? does this do it
p3 <- py$plotly(box, kwargs=list(filename="boxlabeltest", fileopt="overwrite"))

Error in toJSON(unclass(x), container, collapse, ..., .level = .level +  : 
  error in evaluating the argument 'x' in selecting a method for function 'toJSON': Error in unclass(x) : cannot unclass an environment
@xsaintmleux
Copy link

Your last call just needs to be to ggplotly instead of plotly. You can also pass the kwargs on the initial call to name your plot. To create a folder, kwargs$filename can be a complete path, e.g.:

#initialize acccess to the API
py <- plotly()
#create plot
box<-ggplot(iris, aes(factor(Species), Petal.Width)) + geom_boxplot()
#push your plot through the API, with a complete path as its filename
p2 <- py$ggplotly(box, kwargs=list(filename="testfolder/subfolder/boxlabeltest"))
# another plot
box<-ggplot(iris, aes(factor(Species), Petal.Length)) + geom_boxplot()
# replace existing plot with the new one
p3 <- py$ggplotly(box, kwargs=list(filename="testfolder/subfolder/boxlabeltest", fileopt="overwrite"))

Hope this helps!

@jamesthomson
Copy link
Author

amazing. that works perfectly. i should have spotted that myself though. thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants