python - Change main plot legend label text -


so far have been able label subplots fine i'm having issue main one.

here's relevant part of code:

data_bs_p = data[channels[0]] data_bs_r = data[channels[1]] data_bs_y = data[channels[2]] plot_bs_p = data_bs_p.plot() #data_bs_p pandas dataframe axbs = plot_bs_p.gca() axbs.plot(data_bs_r, label='roll') axbs.plot(data_bs_y, label='yaw') axbs.set_ylabel('amplitude (urad)') axbs.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=3,             fancybox=true, shadow=true) ml1 = multiplelocator(10) ml2 = multiplelocator(3600) axbs.yaxis.set_minor_locator(ml1) axbs.xaxis.set_minor_locator(ml2) plot_bs_p.save('l1-sus-bs_m1_damp_pry_inmon.jpg') 

and have far: enter image description here notice lengthy label blue line. i'd labeled "pitch" instead of file name. in line can that?

you need gain access of legend() object , use set_text() change text values, simple example:

plt.plot(range(10), label='some long label') plt.plot(range(1,11), label='short label') l=plt.legend() l.get_texts()[0].set_text('make short') plt.savefig('temp.png') 

enter image description here

in case, changing first item in legend, quite sure 0 index in l.get_texts()[0] applies problem too.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -