Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change the dimensions of a histogram depicted by plt.hist() as figsize is not an argument [duplicate]

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 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?

like image 476
Deshwal Avatar asked Oct 12 '19 09:10

Deshwal


People also ask

Which argument in hist () is used to create a stacked bar type histogram?

histtype : This parameter is an optional parameter and it is used to draw type of histogram. {'bar', 'barstacked', 'step', 'stepfilled'}

How do I increase Figsize in Matplotlib?

If you've already got the figure created, say it's 'figure 1' (that's the default one when you're using pyplot), you can use figure(num=1, figsize=(8, 6), ...) to change it's size etc.

How do you define a Figsize in Python?

Python3. figsize() takes two parameters- width and height (in inches). By default the values for width and height are 6.4 and 4.8 respectively. Where, x and y are width and height respectively in inches.


1 Answers

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')
like image 185
vb_rises Avatar answered Sep 28 '22 08:09

vb_rises