matplotlib - Python pylab plot legend scientivic writing -


i need modify legend. noise_mu has values 1.6e-29 , want being plotted scientific way. unfortunately legend prints them in form of 0.000000000000000000000016 . how can change ?!

pl.figure('connectivity', figsize=(16, 9), dpi=80, facecolor="grey", frameon="true")     pl.ion()     pl.plot(freqs, con, label="$\mu_n: %.30f$"%noise_mu, linewidth=1.5)     pl.ylim(0, 1.05)     pl.xlim(freq1_start-30,freq1_end+30)     pl.xlabel("frequency [hz]", color="black", fontsize=22)     pl.ylabel("connectivity value [ ]", color="black", fontsize=22)     pl.grid(all)     xticks = np.arange(freq1_start-30,freq1_end+30,5) # change ticks accordingly roi     pl.xticks(xticks)     yticks = np.arange(0,1.05,0.1)     pl.yticks(yticks)     leg = pl.legend(prop={'size':16}, shadow=true, fancybox=true)     legobj in leg.legendhandles:         legobj.set_linewidth(2.5)     pl.show() 

plot without specifying formatting

pl.plot(freqs, con, label="$\mu_n: %g$"%noise_mu, linewidth=1.5) 

note %g instead of %.30f

reference : https://docs.python.org/2.4/lib/typesseq-strings.html


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -