Python Matplotlib svg输出表现出奇怪的行为

Python Matplotlib svg输出表现出奇怪的行为,python,svg,matplotlib,Python,Svg,Matplotlib,我正在绘制一段时间内的风分布极坐标图,并将其保存为svg格式,以便将其包含在inkscape中制作的图形中 以下是我的数据示例: import matplotlib.pyplot as plt import numpy as np Theta = np.asanyarray([11.25, 33.75, 56.25, 78.75, 101.25, 123.75, 146.25, 168.75, 191.25, 213.75, 236.25, 258.75,

我正在绘制一段时间内的风分布极坐标图,并将其保存为svg格式,以便将其包含在inkscape中制作的图形中

以下是我的数据示例:

import matplotlib.pyplot as plt
import numpy as np

Theta =  np.asanyarray([11.25,  33.75,  56.25,  78.75, 101.25, 123.75, 146.25, 168.75,
              191.25, 213.75, 236.25, 258.75, 281.25, 303.75, 326.25])

R = np.asanyarray([5.4,2.4,1.2,2.6,5.4,2.3,5.8,5.4,3.3,1.8,1.0,4.0,13.1,7.6,3.2])

fig, axes = plt.subplots(nrows = 1, ncols = 1,subplot_kw={'projection': 'polar'},figsize = (2,2))

axes.set_theta_direction(-1)
axes.set_theta_offset(0)
axes.set_theta_zero_location('N')
axes.set_thetagrids([0,90,180,270],['N','E','S','W'])
axes.bar((Theta)*np.pi/180,R,width=2*np.pi/Theta.shape[0],edgecolor='black')
plt.savefig('Plot1.svg')
当我像这样运行它时,一切正常。然而,我的数据集中的θ表示箱子中心,而它被绘制为箱子边缘,所以我想减去箱子宽度的一半,使其与正确的风向对齐

fig, axes = plt.subplots(nrows = 1, ncols = 1,subplot_kw={'projection': 'polar'},figsize = (2,2))
axes.set_theta_direction(-1)
axes.set_theta_offset(0)
axes.set_theta_zero_location('N')
axes.set_thetagrids([0,90,180,270],['N','E','S','W'])
axes.bar((Theta-11.25)*np.pi/180,R,width=2*np.pi/Theta.shape[0],edgecolor='black')
plt.savefig('Plot2.svg')
两个图之间的唯一区别是从图2中减去一个常数。但是,当我将它们导入inkscape时,它们的大小非常不同

图1是我指定的(2英寸x2英寸),但出于某种原因,图2是(38.357英寸x2英寸)?此外,结果文件的大小不同,绘图1为147 kb,绘图2为145 kb。但是,如果我将它们另存为.png文件,它们都会保持正确的尺寸,并且文件大小相同


我可以在inkscape中剪辑它并解决这个问题,但我只想知道为什么会发生这种情况,以便将来可以防止它发生???

我只是复制了您的代码并在python 2.7中运行了它。使用matplotlib 2.0,两个绘图具有相同的文件大小(141kB)和svg图形大小。使用matplotlib 1.5,Plot1.svg有151kB,Plot2.svg有148KB。但它们在svg文件中的图形大小相同。结论:我无法复制此问题。我也无法使用python 3.5和matplotlib 1.5复制您的问题。这是将svg加载到Inkscape时出现的问题吗?