Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

ax text not placed correclty

import matplotlib.pyplot as plt

# Define some names and variables to go in the text box.
xn, yn, cod = 'r', 'p', 'abc'
prec = 2
ccl = [546.35642, 6785.35416]
ect = [12.5235, 13.643241]

fig = plt.figure()
ax = fig.add_subplot(111)
ax.axis([-1, 10, -1, 1])

# Generate text to write.
text1 = "${}_{{t}} = {:.{p}f} pm {:.{p}f}; {c}$".format(xn, ccl[0],
    ect[0], c=cod, p=prec)
text2 = "${}_{{t}} = {:.{p}f} pm {:.{p}f}; {c}$".format(yn, ccl[1],
    ect[1], c=cod, p=prec)
text = text1 + '
' + text2

ax.annotate(text, xy=(1, 1), xytext=(-15, -15), fontsize=10,
    xycoords='axes fraction', textcoords='offset points',
    bbox=dict(facecolor='white', alpha=0.8),
    horizontalalignment='right', verticalalignment='top')

plt.show()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ax #text #correclty
ADD COMMENT
Topic
Name
5+1 =