1

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
  • 2,881
  • 6
  • 32
  • 52
  • 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

2

Give the figure more height:

fig, ax = plt.subplots(figsize=(15,15))
ax.plot(kind='barh')
plt.show()
yatu
  • 80,714
  • 11
  • 64
  • 111
2

use figsize parameter of plot function

figsize=(length, height)

df.plot(figsize=(20,20), kind='barh')
plt.show()
prisar
  • 2,769
  • 2
  • 23
  • 27