0

enter image description here I am trying to create a histogram but the values seem to be very small, so the size of the histogram is also small. What can I add to make it bigger? This is the code that I have:

plt.hist(my_data["Happiness Score"], bins=15, edgecolor ='white') 
#x and y labels:
plt.xlabel("Frequency")
plt.ylabel("Happiness Score")
textstr= 'Mean = 5.375734\nS.D =1.145010\nn = 158'
plt.text(40,50, textstr)
plt.axvline(x=5.375734,color='red',linestyle="dashed", label='mean')
plt.axvline(x=5.3757348 + 1.145010,color='green',linestyle="solid", label='S.D.')
plt.axvline(x=5.375734 - 1.145010,color='green',linestyle="solid")
plt.legend(loc='center right')
plt.show()
whatup
  • 25
  • 1
  • 5
  • show your answer – ombk Nov 26 '20 at 15:06
  • `plt.figure(figsize=(15,15))` does this solve? – ombk Nov 26 '20 at 15:06
  • are you talking about something like this? https://stackoverflow.com/questions/58352904/how-to-change-the-dimensions-of-a-histogram-depicted-by-plt-hist-as-figsize-is – smitty_werbenjagermanjensen Nov 26 '20 at 15:06
  • @ombk I just added a picture of what I had in the beginning. I have tried implementing your code and it does make the histogram size bigger, but all the other things like labels and text don´t appear anymore. Is there a way to fix that? – whatup Nov 26 '20 at 17:42
  • Yes indeed i gave a huge rescaling, just try 7 by 7 maybe it will look better – ombk Nov 26 '20 at 18:05

1 Answers1

0

I think the fastest way is to use the figure(figsize) command. You can play with the values of the size however you like.

plt.figure(figsize=(10,8))
Paul C.
  • 167
  • 1
  • 8