Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何调整matplotlib散点图的大小_Python_Matplotlib_Scatter Plot - Fatal编程技术网

Python 如何调整matplotlib散点图的大小

Python 如何调整matplotlib散点图的大小,python,matplotlib,scatter-plot,Python,Matplotlib,Scatter Plot,我无法在matplotlib散点图中调整图形的大小。我已经包括了plt.figure(figsize=(20,20)),但它不影响大小 这条线不是你想象的那样 plt.figure(figsize=(20,20)) 它不是调整现有绘图的大小,而是创建一个大小为20x20的新图形。只需在调用District之前移动上面的行,事情就会按照您的意愿进行 plt.figure(figsize=(20,20)) plt.scatter(x['so2_x'],x['state'],alpha=0.5,c

我无法在matplotlib散点图中调整图形的大小。我已经包括了
plt.figure(figsize=(20,20))
,但它不影响大小


这条线不是你想象的那样

plt.figure(figsize=(20,20))
它不是调整现有绘图的大小,而是创建一个大小为20x20的新图形。只需在调用District之前移动上面的行,事情就会按照您的意愿进行

plt.figure(figsize=(20,20))
plt.scatter(x['so2_x'],x['state'],alpha=0.5,c=x['so2_x'],s=x['so2_x'])
plt.title("so2@2011 vs state")    
plt.show()
另一种方法是在调用scatter隐式创建地物对象后更改大小,使用gcf()返回当前地物句柄

plt.scatter(x['so2_x'],x['state'],alpha=0.5,c=x['so2_x'],s=x['so2_x'])
plt.title("so2@2011 vs state")
plt.gcf().set_size_inches((20, 20))    
plt.show()
plt.scatter(x['so2_x'],x['state'],alpha=0.5,c=x['so2_x'],s=x['so2_x'])
plt.title("so2@2011 vs state")
plt.gcf().set_size_inches((20, 20))    
plt.show()