[Matplotlib-users] figsize wrong in Qt5Agg import

David J Pine djpine at gmail.com
Sun May 7 13:45:20 EDT 2017


Using the qt5agg backend, I get plots that are 2 times too small unless I
use pyplot.

I just upgraded to matplotlib 2.01.  I'm running on a Mac using the
Anaconda installation: 4.3.17                   py36_0

This two scripts produce plots that are the same size.  Why do I have to
double the figsize parameters when I do not use pyplot?  Seems like a bug.
I didn't need to do this for the Qt4Agg backend.

# script 1
import matplotlib
matplotlib.use('Qt5Agg')
import matplotlib.pyplot as plt
fig1, ax = plt.subplots(figsize=(6, 4))
ax.plot([1, 2, 3, 2, 3, 4, 3, 4, 5])
ax.set_title('A simple plot')
ax.grid(True)
ax.set_xlabel('time')
ax.set_ylabel('volts')
plt.savefig('test1.pdf')
plt.show()

# script 2
import matplotlib
matplotlib.use('Qt5Agg')
from matplotlib.backends.backend_qt5agg \
     import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
fig = Figure(figsize=(12, 8))
canvas = FigureCanvas(fig)
ax = fig.add_subplot(111)
ax.plot([1, 2, 3, 2, 3, 4, 3, 4, 5])
ax.set_title('A simple plot')
ax.grid(True)
ax.set_xlabel('time')
ax.set_ylabel('volts')
canvas.print_figure('test2.pdf')
canvas.show()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170507/939b41fb/attachment-0001.html>


More information about the Matplotlib-users mailing list