Reputation: 745
I'm trying out R with Jupyter Notebook and for some reason the plots are huge. How can I reduce the size of the plot? I tried changing the plot_scale
option via: options(jupyter.plot_scale=.25
) but nothing happened. I've tried other numbers besides .25, but it has no effect.
I also tried
options(repr.plot.width = 1, repr.plot.height = 0.75, repr.plot.res = 100)
as well as options(jupyter.plot_mimetypes = c("text/plain", "image/png" ))
, but both gave the following error:
Error in value[[3L]](cond): invalid graphics state
Traceback:
plot without title
Ideally, I'm looking for a global solution (i.e. one that changes the default plot size, rather than having to individually scale each plot). Any suggestions?
Upvotes: 0
Views: 1863
Reputation: 9924
Try the following:
options(repr.plot.width = 5, repr.plot.height = 5)
x = seq(0,2*pi, length = 50)
y = sin(x)
plot(x,y)
Then compare it to the output from the following in another cell or after restarting the kernel:
options(repr.plot.width = 15, repr.plot.height = 15)
x = seq(0,2*pi, length = 50)
y = sin(x)
plot(x,y)
You should see a difference.
If you set the width and height to you get plot without title
error.
Should be good with 2 or above because ~1.8 or above worked in my tests.
Based on this post.
Upvotes: 2
Reputation: 802
simply run
dev.off()
then rerun your code for plotting.
Alternativly use ggplot. If the error persists you should still try dev.off() and rerun your code.
Otherwise you still have the option to restart your notebook or reinstall R.
Upvotes: 0