From c7b8dbf6f8a4b6e7c0a9533aa782cd3439d8d61e Mon Sep 17 00:00:00 2001 From: Juergen Fuhrmann Date: Mon, 10 May 2021 22:24:39 +0200 Subject: [PATCH] Set figure size via fig.set_size_inches. This works on the screen and in Pluto notebooks, removing the necessity to close the figure first. --- src/pyplot.jl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/pyplot.jl b/src/pyplot.jl index ce60a06..093834a 100644 --- a/src/pyplot.jl +++ b/src/pyplot.jl @@ -3,11 +3,8 @@ function initialize!(p, ::Type{PyPlotType}) PyPlot.PyObject(PyPlot.axes3D)# see https://github.com/JuliaPy/PyPlot.jl/issues/351 if !haskey(p.context,:figure) res=p.context[:resolution] - p.context[:figure]=PyPlot.figure(p.context[:fignumber]) - if isdefined(Main, :PlutoRunner) # Reset figure for Pluto - PyPlot.close(p.context[:figure]) - end - p.context[:figure]=PyPlot.figure(p.context[:fignumber],figsize=(res[1]/100,res[2]/100),dpi=100) + p.context[:figure]=PyPlot.figure(p.context[:fignumber],dpi=100) + p.context[:figure].set_size_inches(res[1]/100,res[2]/100,forward=true) for ctx in p.subplots ctx[:figure]=p.context[:figure] end