Plot size with IRKernel

2,841 views
Skip to first unread message

Friso van Vollenhoven

unread,
Mar 20, 2015, 6:03:45 AM3/20/15
to jup...@googlegroups.com
Hi all,
I'm using Jupyter which comes when installing ipython[all] through pip with the IRKernel from https://github.com/takluyver/IRkernel. When plotting with ggplot in R, the plots are only 50% of my screen width. Question: is it possible to configure the plot size somewhere?

When using R through rpy2 / rmagic, it is possible to set the plot size as parameter to the R cell level magic, but this notebook is entirely in R.

Normally in R, setting the plot size is set on the surface that you are plotting on, but from the notebook, I think there is no way to access it.


Thanks for any help, cheers,
Friso

Matthias Bussonnier

unread,
Mar 20, 2015, 2:32:09 PM3/20/15
to jup...@googlegroups.com
So there are two way (IIRC) to set the port size from a protocol point of view. 
Either you send more pixels with a bigger image, 
Or you  set a width/height with the metadata alongside the images. 

In both cases, the way to do it will most likely depends on the kernels. 
I'm not a R user, but to the extend of my knowledge, R kernel have R write 
the file to disk, and read it again to display it. 
I suppose it can be improved, but that have to be done directly on the in R kernel.

I would suggest Asking the question on R issue tracker. But I guess the most probable answer will that 
this is not implemented yet and that PRs are welcome. 

Hope that helps. 
-- 
M






Thanks for any help, cheers,
Friso


--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/0cd9ca75-ea04-4dbb-b41a-7791fbcfdc01%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Kluyver

unread,
Mar 20, 2015, 2:42:30 PM3/20/15
to jup...@googlegroups.com
On 20 March 2015 at 03:03, Friso van Vollenhoven <f.van.vo...@gmail.com> wrote:
Normally in R, setting the plot size is set on the surface that you are plotting on, but from the notebook, I think there is no way to access it.

You should be able to call IRkernel::set_plot_options() with any of the arguments that you can give to png().

Thomas

Friso van Vollenhoven

unread,
Mar 21, 2015, 2:41:08 AM3/21/15
to jup...@googlegroups.com
Works like a charm!

Thank you,
Friso

chris warth

unread,
May 22, 2015, 7:04:02 PM5/22/15
to jup...@googlegroups.com

Can you be specific about what works for you?

My experience is that this works and gives me a nice wide plot:
IRkernel::set_plot_options(width=600,units="px")


But adding other units does not.  In fact it causes the IRkernel to crash and restart:

IRkernel::set_plot_options(width=6, units="cm")
IRkernel::set_plot_options(width=6, units="in")

What options did you try that seemed to work for you?


On Friday, March 20, 2015 at 11:41:08 PM UTC-7, Friso van Vollenhoven wrote:
Works like a charm!

chris warth

unread,
May 22, 2015, 7:42:01 PM5/22/15
to jup...@googlegroups.com
updated IRKernel to the latest version available on github (as of 5/22/2015) and it appears the method described above is now deprecated.
The current blessed method to set the plot size when using R from inside IPython notebook is


options(repr.plot.width = 6)
options(repr.plot.height = 4)

plot(1:10)


The units appear to be "inches" and I could not find an obvious way to change that. 

The complete list of plot-related options appears to be,
repr.function.highlight
repr.matrix.latex.colspec
repr.plot.antialias
repr.plot.family
repr.plot.height
repr.plot.pointsize
repr.plot.quality
repr.plot.res
repr.plot.width
repr.vector.quote


Friso van Vollenhoven

unread,
May 23, 2015, 6:04:26 AM5/23/15
to jup...@googlegroups.com
What I used is:
IRkernel::set_plot_options(width=950, height=600, units='px')

Here's a rendered notebook with that option (first cell, last line): http://blog.godatadriven.com/static/images/meetup-notebooks/r-plots.html

I haven't tried any other units, so cannot tell you if those worked for me, but pixels do ('px'). It seems indeed that this method is now deprecated in favor of a new approach to setting options. I haven't tried this new style yet. It appears to rely on a separate package called repr (which you'd need to install separately), which allows for configuration of plots and such.


Best,
Friso


--
You received this message because you are subscribed to a topic in the Google Groups "Project Jupyter" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jupyter/623EFF2_yQg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jupyter+u...@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages