i making plot , want text crop @ edge. right hangs on edge, great readability, not want.
here's toy version of i'm doing:
import numpy np import matplotlib.pyplot plt %matplotlib inline fig = plt.figure() ax = fig.add_subplot(111) ax.scatter(np.random.random(10), np.random.random(10)) ax.text(0.8, 0.5, "a rather long string") plt.show() just clear, want crop text element, not else — e.g. want leave 0.9 in x-axis alone.
you should set clipbox text described in documentation:
import numpy np import matplotlib.pyplot plt %matplotlib inline fig = plt.figure() ax = fig.add_subplot(111) ax.scatter(np.random.random(10), np.random.random(10)) ax.text(0.8, 0.5, "a rather long string", clip_box=ax.clipbox, clip_on=true) ax.set_xlim(0, 1) plt.show() this results in


Comments
Post a Comment