1
私は曲線をプロットしてズームし、私のプロットの特定の部分のズームを示すインセットを持っています。これは、部分的にこれを実現私のコードです:matplotlibプロットのインセットズームが間違ったコーナーに表示される
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from mpl_toolkits.axes_grid1.inset_locator import mark_inset
fig, ax = plt.subplots()
axins = inset_axes(ax, 1,1 , loc=2, bbox_to_anchor=(.08, 0.35),bbox_transform=axfft.figure.transFigure)
x = np.linspace(0, 3, 100)
y = x**2
ax.plot(x, y)
axins.plot(x, y)
x1, x2, y1, y2 = 1, 2, .5, 4.5 # specify the limits
axins.set_xlim(x1, x2) # apply the x-limits
axins.set_ylim(y1, y2) # apply the y-limits
plt.xticks(visible=False)
plt.yticks(visible=False)
mark_inset(ax, axins, loc1=2, loc2=3, fc="none", ec="0.5")
これは、それが生成する出力です:
私の質問:
どのように私はmark_inset
の上に線を入れて作ることができます左のものの代わりに挿入物の右隅?現在の方法では、インジケータ線が私のインセットを横切り、私はそれを望んでいません。
を使用することである、すなわち、ありがとうございますが、このソリューションは、y軸スパンの大部分にまたがる領域には機能しません。すごく高い。それは私の場合にも当てはまります。 – HeinzKurt
その場合、 'mark_inset'を使用することはできず、代わりに接続線を別々に描画する必要があります。 'matplotlib.patches.ConnectionPatch'はそうするのに役立ちます。 – ImportanceOfBeingErnest