I'd like to make a plot in RStudio , save it + view it. This is so that I can iterate on aspects of plotting (e.g. size of elements). I don't want to work just in the Plots pane in RStudio, as the size of the canvas when saving files is an important element of how the final plot looks.
Currently, I'm finding I need to upload then download the files to view, which is very slow + also risks accidentally downloading data unintentionally (as you can't view the plot to check it contains only the info you think). Is there a better way round this?
For additional context I'm saving with:
svg("my_file.svg")
my_plot
dev.off()
... though I've also tried with png without success.
Thanks @Ondrej Klempir?! That's now working. Turns out I'd managed to save an empty png file, which was why I couldn't get that to work :) In case it's useful to others, for svg RStudio by default tries to open as if it were a text file. But using the path as you did works!
Comments
3 comments
Why you need to upload and then download the files?
I am wondering whether the following is something you are looking for:
#some sample data
head(diamonds)
#to see actually what will be plotted and compare
qplot(clarity, data=diamonds, fill=cut, geom="bar")
#save the plot in a variable image to be able to export to svg
image=qplot(clarity, data=diamonds, fill=cut, geom="bar")
#This actually save the plot in a image
ggsave(file="test.png", plot=image, width=10, height=8, dpi = 300, units = "in", device='png')
Similarly for the exported svg file format, I just changed the "png" in path to "svg" and svg is loaded:
Thanks @Ondrej Klempir?! That's now working. Turns out I'd managed to save an empty png file, which was why I couldn't get that to work :) In case it's useful to others, for svg RStudio by default tries to open as if it were a text file. But using the path as you did works!
Please sign in to leave a comment.