открытая множественная вставка не работает в matplotlib - PullRequest
0 голосов
/ 31 мая 2019

Я хочу открыть несколько осей на фигуре.Однако я получаю следующее предупреждающее сообщение, и отображается только последняя вставная панель.

/usr/lib/python2.7/dist-packages/matplotlib/cbook/deprecation.py:106: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
  warnings.warn(message, mplDeprecation, stacklevel=1)

Вот код:

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import InsetPosition

fig, ax= plt.subplots()

iax = plt.axes([0, 0, 1, 2])
ip = InsetPosition(ax, [0.4, 0.5, 0.2, 0.2]) #posx, posy, width, height
iax.set_axes_locator(ip)
iax.plot([1,2,4])

iax1 = plt.axes([0, 0, 1, 2])
ip = InsetPosition(ax, [0.7, 0.2, 0.2, 0.2]) #posx, posy, width, height
iax1.set_axes_locator(ip)
iax1.plot([1,2,4])

У вас есть идеи?

1 Ответ

0 голосов
/ 31 мая 2019

Просто серьезно отнеситесь к предупреждению и сделайте, как это предлагается в

. Между тем, это предупреждение можно подавить и обеспечить дальнейшее поведение, передав уникальную метку каждому экземпляру осей.

, а именно, используйте уникальные метки для каждой оси:

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import InsetPosition

fig, ax= plt.subplots()

iax = fig.add_axes([0, 0, 1, 2], label="iax")
ip = InsetPosition(ax, [0.4, 0.5, 0.2, 0.2]) #posx, posy, width, height
iax.set_axes_locator(ip)
iax.plot([1,2,4])

iax1 = fig.add_axes([0, 0, 1, 2], label="iax1")
ip = InsetPosition(ax, [0.7, 0.2, 0.2, 0.2]) #posx, posy, width, height
iax1.set_axes_locator(ip)
iax1.plot([1,2,4])

plt.show()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...