これは少し説明が難しいものです。基本的には、インセットプロットを作成し、mpl_toolkits.axes_grid1.inset_locator.mark_insetの利便性を利用したいが、インセットプロットのデータを親軸のデータとは完全に独立させたい。私が使用したい機能を有するmatplotlibインセットプロット内の異なるデータを持つmark_inset
:
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
from mpl_toolkits.axes_grid1.inset_locator import InsetPosition
data = np.random.normal(size=(2000,2000))
plt.imshow(data, origin='lower')
parent_axes = plt.gca()
ax2 = inset_axes(parent_axes, 1, 1)
ax2.plot([900,1100],[900,1100])
# I need more control over the position of the inset axes than is given by the inset_axes function
ip = InsetPosition(parent_axes,[0.7,0.7,0.3,0.3])
ax2.set_axes_locator(ip)
# I want to be able to control where the mark is connected to, independently of the data in the ax2.plot call
mark_inset(parent_axes, ax2, 2,4)
# plt.savefig('./inset_example.png')
plt.show()
コード例は、次の画像を生成する青色のボックスの位置は全体でax2.plot()への入力データによって制御されます。私は手動で青いボックスを配置し、私がax2にしたいものを入力したいと思います。これは可能ですか?
クイック編集:明確にするために、インセットプロットにデータがリンクされている理由を理解しています。したがって、これを達成するためにmatplotlibに完全に異なる方法がある場合は、自由にその点について返信してください。しかし、大きな画像にかなりの数のインセットが必要なので、私が配置するすべての軸に手作業でボックスや線を配置するのを避けようとしています。
あなたのハックは、インセット内のデータを台無しにしながら、私は、青い箱の位置が...だけでなく、私のハックを台無しに、このようなものを考えられていました。複数のオプションがあると便利で、mplのソースコードをハックする必要はありません。 –