我看到了这个关于如何创建平行坐标图的示例: 平行坐标:

enter image description here

这创建了一个漂亮的平行坐标图,但我想将此图添加到子图中已有的图(同一图中它旁边应该有另一个图)。

对于已经存在的图形,图形和轴定义为:

fig = plt.figure(figsize=plt.figaspect(2.))
ax =  fig.add_subplot(1,2,1)

对于平行坐标,他们建议:

fig, axes = plt.subplots(1, dims-1, sharey=False)

如何协调图形和轴的初始化?

有帮助吗?

解决方案

一种选择是使用创建所有轴 subplots 然后只需移动您不想要的那个的位置 wspace=0 正如对平行坐标图所做的那样:

import matplotlib.pylab as plt

dims = 4
fig, axes = plt.subplots(1, dims-1 + 1, sharey=False)

plt.subplots_adjust(wspace=0)

ax1 = axes[0]
pos = ax1.get_position()
ax1.set_position(pos.translated(tx = -0.1,ty=0))

enter image description here

我已将 1 添加到创建的列数(显式保留为 -1+1)并设置 wspace=0 它将所有图绘制为彼此相邻且中间没有空格。取最左边的轴并获得位置 盒子. 。这很好,因为它使您能够通过以下方式翻译它: tx=-0.1 分离你现有的人物。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top