我试图使用matplot、python2.7和windows7将图形保存到pdf。我可以将图形另存为.png,但当我试图将其保存为.pdf时,文件是空白的。下面是一些示例代码:import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
x = [1, 2, 3, 4, 5]
y = [6, 7, 8, 9, 10]
linewidthPlot = '2'
linestylePlot = '-'
markerPlot = 'o'
colorPlot = 'b'
xlabel = 'x'
ylabel = 'y'
title = 'x v y'
# Plot the data using matplot.
fig1 = plt.figure()
ax1 = fig1.gca()
line1, = plt.plot(x, y, linewidth=linewidthPlot,
linestyle=linestylePlot, marker=markerPlot, color=colorPlot)
axisScale = 0.05
xmin = min(x) - (axisScale * (max(x) - min(x)))
xmax = max(x) + (axisScale * (max(x) - min(x))