Matplotlib 在子地块中显示hypertools绘图

Matplotlib 在子地块中显示hypertools绘图,matplotlib,subplot,hypertools,Matplotlib,Subplot,Hypertools,我想将一些超级工具绘图安排到matplotlib子绘图的网格中。通常hypertools.plot会立即渲染,但可以通过传递show=False来停止渲染。它还返回一个hypertools.DataGeometry`对象。如何将其渲染为网格中的子地块而不是独立图形?为matplotlib编写打印包装的通常方法是允许向包装提供轴,例如 def plot(data, ax=None): if not ax: fig, ax = plt.subplots() else:

我想将一些超级工具绘图安排到matplotlib子绘图的网格中。通常hypertools.plot会立即渲染,但可以通过传递show=False来停止渲染。它还返回一个hypertools.DataGeometry`对象。如何将其渲染为网格中的子地块而不是独立图形?

为matplotlib编写打印包装的通常方法是允许向包装提供轴,例如

def plot(data, ax=None):
    if not ax:
        fig, ax = plt.subplots()
    else:
        fig = ax.figure
    # plot to ax ...
hypertools不遵循这种标准方法,这将使将其中一个绘图转换为现有图形非常麻烦。 可能值得将此作为一个问题放到他们的GitHub跟踪器上

您可以选择将轴从hypertools创建的图形移动到您自己的图形

这可以使用来自的方法来完成。我无法测试以下内容,因为我没有可用的超级工具

import matplotlib.pyplot as plt
import hypertools

datageom = hypertools.plot(..., show=False)

ax = datageom.ax
ax.remove()

fig2 = plt.figure()
ax.figure=fig2
fig2.axes.append(ax)
fig2.add_axes(ax)

dummy = fig2.add_subplot(231)
ax.set_position(dummy.get_position())
dummy.remove()
# possibly:
# plt.close(datageom.fig)

plt.show()