Space
Space

Reputation: 51

How to add more space in between Y-points in a barh()?

Image: http://s11.postimg.org/r1f6kgq2r/Screenshot_from_2016_02_19_17_03_30.png

Should be pretty clear from the image; basically I want the Y-labels to be visible. How do I add more spacing between them? My code is as follows:

  1 import numpy as np
  2 import matplotlib.pyplot as plt
  3 import sys
  4 
  5 file_hours = sys.argv[1]
  6 file_bytes = sys.argv[2]
  7 
  8 list_hours = []
  9 list_bytes = []
 10 for line in open(file_hours, 'r'):
 11     list_hours.append(line)
 12 for line in open(file_bytes, 'r'):
 13     list_bytes.append(float(line))
 14 
 15 y_pos = np.arange(len(list_hours))
 16 fig = plt.figure()
 17 
 18 plt.barh(y_pos,list_bytes,align='center')
 19 plt.yticks(y_pos, list_hours)
 20 plt.show()

EDIT: Goes without saying that I have a large amount of data to graph. I doesn't matter if the graph is (much) taller.

Upvotes: 2

Views: 1525

Answers (1)

mechanical_meat
mechanical_meat

Reputation: 169414

You can do something like:

fig = plt.figure(figsize=(8,36)) 

where the first number is the width and the second is the height. Reference: http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure

You can also space out the yticks, e.g:

plt.yticks(np.arange(min(y_pos), max(y_pos), 5.0)

Upvotes: 4

Related Questions