python - matplotlib make histogram fill plot area -


i doing plot using matplotlib , bothered fact plot area bigger area occupied histogram patches. here problem:

histogram narrow or axes wide ?

you see, rid of empty space between "23" patch end plot's right border.

here code:

lines = (' '.join(line.strip().split()) line in open(filename) if line.strip()) #prepare date strings local_dates = ( pytz.utc.localize(datetime.datetime.strptime(dt, "%y-%m-%d %h:%m:%s.%f")).astimezone(localtz) dt in lines )  local_dates = list(local_dates)  #plot hour of day bins = range(25)  n,bins,patches = plt.hist([ t.hour t in local_dates], bins=bins )  xticks_pos = [0.5*patch.get_width() + patch.get_xy()[0] patch in patches]  plt.xticks(xticks_pos, range(25),  ha='center')   plt.xlabel('ora') plt.ylabel('numar de evenimente')  plt.title(filename, y=1.03)  fig = plt.gcf() fig.set_size_inches(12,8) plt.subplots_adjust(left=0, right=1, top=0.9, bottom=0.1) plt.savefig(filename+'.by_hour.png', dpi=100,bbox_inches='tight') plt.clf() 

so can make patches stretch entire plot viewport , how ?


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -