Wednesday, 15 April 2015

python - How to add text to matplotlib legend and maintain equal space with legend and plot borders? -


I am attempting to add a text to matplotlib legend which can be done separately by adding annotation but I can see them in a box How should I: nppy import matplotlib.pyplot plt a = np.array ([1, 2, 3, 4, 5, 6,]) as import:

  B = A ** 2c = a ** 3 fig = plt.figure (1, figs = (5, 5)) fig.clf () plot = plt.subplot (111) plot.plot (A, B, linestyl = '- Plot.plot (A, C, linestyle = '-', marker = '^', label = 'cubic')) plot.legend (title = 'Lorem ipsum', 'marker =' ^ ', label =' ^ ' , Label = 'quadratic' N '+ str (A [1]) +' Dollar site AMT, \ n Plot.set_ylabel ('y') plot.set_xlabel ('x') plt.savefig ('test.pdf', bbox_inches = '' 'Tight')  

And at the same time, I need the space between the plot and the legend border, as mythology increases in width, so the story sets forth the legend without rational change. Should, as shown in Figure S, that the opposition should be Tant:

  + ---------------------- --------------------------------- + | | | | | | + ---------- + | | | | | | S | | | | & Lt; --- & gt; | | | | | | | | | | | | | | | | + ---------- + | | | | | | | | | | | | | | | | | | + ------------------------------------------------- ----- +  

There is no easy way to add text to the legend and to keep constant spacing with text alignment options in the script box and so on.


No comments:

Post a Comment