Davide-sd / sympy-plot-backends

An improved plotting module for SymPy
BSD 3-Clause "New" or "Revised" License
44 stars 10 forks source link

why the figure-size gets smaller after setting "ax" #37

Closed imakn634 closed 7 months ago

imakn634 commented 7 months ago

I would like to know why the figure-size gets smaller after setting "ax". Is is possible for the size to remain unchanged?

from sympy.abc import *
from sympy import *
from spb import *

plot(-x**2, (x, -1, 1))

fig1

p=plot(-x**2, (x, -1, 1), show=False)
ax=p.ax
ax.grid(linestyle = 'dotted')

fig2

After setting "ax=p.ax", the figure-size gets slightly smaller.

If possible, I would like to know how to set the size unchanged.

Davide-sd commented 7 months ago

Because the p.show method applies tigh_layout() to the figure:

p = plot(-t**2, (t, -1, 1), show=False)
fig = p.fig
ax = p.ax
fig.tight_layout()
ax.grid(linestyle = 'dotted')
imakn634 commented 7 months ago

Thank you! fig.tight_layout() woks!

Davide-sd commented 7 months ago

I'm closing the issue :)