2

I have a dataframe with one column and 80 rows, and I want to visualize it as a horizontal bar chart. I use pandas plot() function like this:

df.plot(kind='barh')
plt.show()

But, because my dataframe has too many rows, the result is enter image description here

How I can make the figure longer? Becasue I think if the figure becomes longer, all the row information will fit into the vertical axis.

amiref
  • 3,181
  • 7
  • 38
  • 62
  • 1
    Have you tried the previous SO question? [How to change the size of figures in Matplotlib?](https://stackoverflow.com/questions/332289/how-do-you-change-the-size-of-figures-drawn-with-matplotlib) – Alex_P Nov 12 '18 at 17:09
  • you can use `ax.set_position` – It_is_Chris Nov 12 '18 at 17:11

2 Answers2

3

use figsize parameter of plot function

figsize=(length, height)

df.plot(figsize=(20,20), kind='barh')
plt.show()
prisar
  • 3,041
  • 2
  • 26
  • 27
2

Give the figure more height:

fig, ax = plt.subplots(figsize=(15,15))
ax.plot(kind='barh')
plt.show()
yatu
  • 86,083
  • 12
  • 84
  • 139