How to autoscale y axis in matplotlib? -


this question has answer here:

i'm creating many plots , great while other need adjustment. below how can make hard see plot line easier see without having manually plot them? plot 50-100 of these @ time add them pdf report. i'd add space under line, example have ylim min limit set -0.1, automatically.

this 1 hard see plot line: hard see plot line

this 1 easy see plot line: easy see plot line

here code plotting:

def plot(chan_data): '''uses matplotlib plot channel ''' f, ax = plt.subplots(1, figsize=(8, 2.5)) x = dffinal['time'].keys()     ax.plot(x, dffinal[chan_data].values, linewidth=0.4, color='blue') ax.xaxis.set_major_formatter(mdates.dateformatter('%m/%d/%y - %h:%m')) ax.xaxis.set_major_locator(mdates.autodatelocator(interval_multiples=true))  lgd1 = ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))  f.autofmt_xdate() ax.set_ylabel(dffinal[chan_data].name) ax.grid('on')  #i've tried these no luck #ax.autoscale(enable=true, axis='y', tight=false) #ax.set_ymargin(0.5) #ax.set_autoscaley_on(true)  fname = ".\\plots\\" + chan_data + ".png" print "creating: " + fname plt.savefig(fname, dpi=100, bbox_extra_artist=(lgd1,), bbox_inches='tight') plt.close() return fname     

you want margins doc

ex

ax.margins(y=.1) 

also see add margin when plots run against edge of graph


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -