私は、3つのサブプロットでこのグラフを作成していますが、それぞれのインセット軸が必要ですが、コードでは最後のサブプロットのインセット軸のみが作成されます。これで私を助けてください。ありがとう。複数のサブプロットを持つときmatplotlibのInsetPositionで問題が発生する
import pylab as pl
from mpl_toolkits.axes_grid1.inset_locator import InsetPosition
def test(ax_main, pos, Data):
ax2 = pl.axes([0, 0, 1, 1])
ip = InsetPosition(ax_main, pos)
ax2.set_axes_locator(ip)
pl.hist(Data)
for i in range(3):
ax=pl.subplot(1,3,i+1)
Data = pl.rand(100)
ax.plot(Data)
test(ax, [.3,.3,.6,.6], Data)
EDIT:
私はinset_axesを使用してこの問題を回避できます。
from mpl_toolkits.axes_grid.inset_locator import inset_axes
def test(ax_main, pos, Data):
ax2 = inset_axes(ax_main, weight=pos[2], height=pos[3]) # weight and height are not important here because they will be changed in the next lines
ip = InsetPosition(ax_main, pos)
ax2.set_axes_locator(ip)
pl.hist(Data)
for i in range(3):
ax=pl.subplot(1,3,i+1)
Data = pl.rand(100)
ax.plot(Data)
test(ax, [.3,.3,.6,.6], Data)
おかげで、私はまた、リポジトリにこのスレッドを見たが、それ以降をインストールしてみてくださいませんでしたmatplotlibのバージョン:[https://github.com/matplotlib/matplotlib/issues/9024](https://github.com/matplotlib/matplotlib/issues/9024) – ses