python - Maptlotlib: add zoomed region of a graph with anisotropic (axis dependent) zoom -
python - Maptlotlib: add zoomed region of a graph with anisotropic (axis dependent) zoom -
i'm trying plot done using python.matplotlib in add together first plot zoomed part in box located in lower right corner.
looking @ documentation , examples, know done using zoomed_inset_axes seems take 1 factor zooming/dilating both directions when i'd dilate along y axis (looking @ attached image easy guess why). tried give bbox scaled doesn't seem trick. there axis transformation or info operation help me?
the reddish arrows , box described size box take (more or less, i'll tune later of course).
edit:
i've been playing bit more , problem seems 2 graphs, in current state, share same y-axis scale.
here code, way, should have been included in first place:
ax = plt.gca() axins = zoomed_inset_axes(ax, 1, loc=4) axins.scatter(x,y, lw=0.1,c="#1b9e77",alpha=0.8) x1, x2, y1, y2 = -75, 5200, -0.31, -0.18 #coordinates of part i'm zooming in axins.plot(n.linspace(x1,x2,100),[-0.25]*100,c="#efd807",lw=3) #yellow line axins.set_xlim(x1, x2) axins.set_ylim(y1, y2) mark_inset(ax, axins, loc1=3, loc2=1, fc="none", ec="0.5")
an alternative method zoomed_inset_axes 'manually'. i'm sure there short comings method if people know of them please comment. no means suggesting best method - 1 i've seen about.
import matplotlib.pyplot plt import numpy np x = np.linspace(0, 100, 1000) y = np.sin(x) ax = plt.subplot(111) ax.plot(x, y) ax.set_ylim(-50, 10) ax2 = plt.axes([0.2, 0.2, .6, .2]) ax2.plot(x, y) mark_inset(ax, ax2, loc1=2, loc2=1, fc="none", ec="0.5") plt.show() this reply adapted this original post.
an altenative method proposed in this so post.
python matplotlib
Comments
Post a Comment