Automatic placement of a text box? ie empty legend [matplotlib]
Christopher Barrington-Leigh
christopherbl at gmail.com
Wed Jun 29 11:44:40 EDT 2011
I still need help with this.
I'd like to have the Sample A box place itself in the optimal empty space, so as not to overly any graphing elements (if possible):
import numpy.random
import matplotlib.pyplot as plt
fig = plt.figure(1, figsize=(5,5))
fig.clf()
ax = fig.add_subplot(111)
ax.set_aspect(1)
x1 = -1 + numpy.random.randn(100)
y1 = -1 + numpy.random.randn(100)
x2 = 1. + numpy.random.randn(100)
y2 = 1. + numpy.random.randn(100)
ax.scatter(x1, y1, color="r")
ax.scatter(x2, y2, color="g")
bbox_props = dict(boxstyle="round", fc="w", ec="0.5", alpha=0.9)
ax.text(-2, -2, "Sample A", ha="center", va="center", size=20,
bbox=bbox_props)
plt.draw()
plt.show()
More information about the Python-list
mailing list