如何更改由plt.hist()表示为figsize的直方图的尺寸不是参数 [英] how to change the dimensions of a histogram depicted by plt.hist() as figsize is not an argument

查看:183
本文介绍了如何更改由plt.hist()表示为figsize的直方图的尺寸不是参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用numpy数组绘制一系列直方图.

I am trying to plot a histogram with a series using numpy array.

n,bins,patch = plt.hist(ser,bins=10, color='green', alpha=0.8, label='Value', edgecolor='orange', linewidth=2)
plt.legend()
plt.ylabel('No of bags', size='x-large')
plt.xlabel('Money in US $', size= 'x-large')

IT运作良好,但是大小很小.我尝试使用 olt.hist(figsize =(8,8)),但它会按预期抛出错误.

IT is working well but the size is spo small. I tried using olt.hist(figsize=(8,8)) but it throws error as expected.

如何增加直方图的大小?

How can I increase the size of my histogram figure?

推荐答案

plt.figure(figsize=(8,8)) #change your figure size as per your desire here
n,bins,patch = plt.hist(ser,bins=10, color='green', alpha=0.8, label='Value', edgecolor='orange', linewidth=2)
....
....

要更改背景颜色和边框颜色,请执行以下操作:

To change the background color and the border color:

plt.figure(figsize=(8,8),facecolor='red',edgecolor='blue')

这篇关于如何更改由plt.hist()表示为figsize的直方图的尺寸不是参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆