I am having trouble reducing a matplotlib figure's size with the TkAgg backend.
First, let me show that I can increase a figure's size. After running the following code,
import matplotlib as mpl
mpl.use('TkAgg')
import matplotlib.pyplot as plt
plt.ion()
fig = plt.figure(figsize = [2, 8])
fig.set_size_inches([8,8], forward = True)
fig.canvas.draw()
print fig.get_size_inches()
a call to fig.get_size_inches()
gives [ 8, 7.475]
. It is a bit annoying that I get 7.475
instead of 8
, but I can deal with that. Next, when I run the following code
import matplotlib as mpl
mpl.use('TkAgg')
import matplotlib.pyplot as plt
plt.ion()
fig = plt.figure(figsize = [8, 8])
fig.set_size_inches([2,8], forward = True)
fig.canvas.draw()
print fig.get_size_inches()
then a call to fig.get_size_inches()
gives [ 6, 7.475]
. A reduction to 6
is a far cry from 2
. Note that interactive mode must be on. If I turn interactive mode off (plt.ioff()
) the TkAgg backend gives [8, 8]
and [2, 8]
, but the shape of the figure windows still look more like [8, 7.475]
and [6, 7.475]
.
If I switch to the Qt4Agg backend, the problem goes away. Unfortunately I cannot get the Qt4Agg backend to work with Spyder. I set Qt4Agg as the backend in Preferences -> Console -> external modules -> GUI backend, and restart Spyder. A call to mpl.get_backend()
returns MacOSX
.
I would like a backend that works with Spyder, allows me to force the figure window to be on top of all other windows (see this post), and allows me to change the figure window size at will.
In case it matters, I am running matplotlib 1.3.1, and Enthought Canopy Python 2.7.6.
UPDATE: I got the Qt4Agg backend to work with Spyder. If no one posts a solution to make the TkAgg backend work properly by this evening, then I will post how to use Qt4Agg with Spyder.