Monday, 15 February 2010

python - offsetbox in matplotlib has too much space at the bottom -


I am using the following to attract the text box:

Enter image details here

The text box clearly shows too many places below and enough on top is not.

Why does this happen and how can I fix it?

(Add: I've opened an over on the tracker of matplotlib )


MWE

< Pre> Import matlotlib.pyplot as plt import matplotlib.offsetbox offsetbox Import gridpec as matplotlib.gridspec Random DF scatter_plot (x, y): Ax = plt.subplot (gs [0: 2, 0: 2]) # Add text box text1 = '$ N = {} $ \ n'.format (0) text2 =' $ a = {} \ pm {} $ \ N '. Format (0.01, 0.01) text3 = '$ log (b) = {} \ pm {} $ \ n'. Format (1.2, 0.3) text 4 = '$ C _ {{(AAA)}} = {} \ Pm {} $ \ n'.format (0.2, 0.05) text5 =' $ D_o = {} \ pm {} $ \ N '. Format (10.6, 0.7) text6 = '$ E_ {{\ Odot}} = {} \ pm {} $ \ n'. Format (100., 200.) text7 = '$ F _ {{fff}} = {} \ Pm {} $' Format (0.5, 0.3) text = text1 + text2 + text3 + text4 + text5 + text6 + text7ob = offsetbox. Encarded text (text, public = 1, prop = dict (size = 12)) Ob.patch.set (boxstyle = 'square, pad = 0.2', alpha = 0.85) ax.add_artist (ob) plt.scatter (x, y) # generate random data for x = [random.random () Xrange (100)] for y = [random.random ()) xrange (100)] # Set the size of the output figure Fig = plt.figure (figsize = (30, 25)) # Make the top-level container gs = Gridspec.gridSpec (10, 12) #g Create e-Speak object # Create plot. Scatter_plot (X, Y) # Save the plot to the file. Fig.tight_layout () plt.savefig ('out.png', dpi = 150)

< P> If I want to understand well, then you

  ob = offsetbox.  

Update:

P> OK, it seems that this problem is a subscript that you are using the last line of the ATH box.

  text7 = '$ f _ {{fff}} = {} \ pm {} $' Format (0.5, 0.3)  

If you skip it, and type:

  text7 = '$ F = {} \ pm {} $ '. Format (0.5, 0.3)  

The same pad is up and down

You can use code to check the code, and from one line _ {{t}} can extract an example and see the result.

> I was only able to find this solution, if someone knows that there is a fix for this, then it would be great.


No comments:

Post a Comment