How to change plot size in jupyter?

Hi,

is it possible to change size of plotted figures in jupyter notebook?
(E.g., with the R kernel I can use “options(repr.plot.width=4, repr.plot.height=3)” but I didn’t find something similar for the Julia kernel).

Thanks

1 Like

The setting is somewhere in IJulia. Sorry that was super unhelpful. I was looking for the setting but now I can’t seem to find it.

It depends on which plotting library you are using.

For example, with Gadfly.jl you can set the plot size using Gadfly.set_default_plot_size(10cm, 8cm) and this will be reflected in the Jupyter notebook.

3 Likes

If you’re using Plots.jl you can do:

using Plots

x = 1:10
y = rand(10)

plot(x, y, size = (700, 700))
8 Likes

Thanks @tlnagy and @brilhana for the Gadfly and Plots methods.

For ggplot2 via RCall in IJulia:

RCall.rcall_p(:options, rcalljl_options=Dict(:width => <width>, :height => <height>))

Full example:

using RCall
using RDatasets
@rlibrary ggplot2
mtcars = dataset("datasets", "mtcars")
RCall.rcall_p(:options, rcalljl_options=Dict(:width => 1000, :height => 800))
ggplot(mtcars) + aes(x=:MPG, y=:HP) + geom_point()

For some more details see file ijulia.jl in package RCall.jl.

4 Likes