所以我有8个3D图(7个3D图和一个2D图)
我想把它们定位成4 x 2的格式。下面是我的代码:
sensor_data = self._util_sensor(sub_df)
fig = plt.figure()
fig.tight_layout()
ax = fig.add_subplot(1, 2, 1, projection = '3d')
ax.scatter(sensor_data['chest'][0], sensor_data['chest'][1], sensor_data['chest'][2])
ax.set_title('Chest')
ax = fig.add_subplot(1, 2, 2)
ax.scatter(sensor_data['ecg'][0], sensor_data['ecg'][1])
ax.set_title('ECG')
ax = fig.add_subplot(2, 2, 1, projection = '3d')
ax.scatter(sensor_data['left_accel'][0], sensor_data['left_accel'][1], sensor_data['left_accel'][2])
ax.set_title('left accel')
ax = fig.add_subplot(2, 2, 2, projection = '3d')
ax.scatter(sensor_data['left_gyro'][0], sensor_data['left_gyro'][1], sensor_data['left_gyro'][2])
ax.set_title('left gyro')
ax = fig.add_subplot(3, 2, 1, projection = '3d')
ax.scatter(sensor_data['left_mag'][0], sensor_data['left_mag'][1], sensor_data['left_mag'][2])
ax.set_title('left mag')
ax = fig.add_subplot(3, 2, 2, projection = '3d')
ax.scatter(sensor_data['right_accel'][0], sensor_data['right_accel'][1], sensor_data['right_accel'][2])
ax.set_title('right accel')
ax = fig.add_subplot(4, 2, 1, projection = '3d')
ax.scatter(sensor_data['right_gyro'][0], sensor_data['right_gyro'][1], sensor_data['right_gyro'][2])
ax.set_title('right gyro')
ax = fig.add_subplot(4, 2, 2, projection = '3d')
ax.scatter(sensor_data['right_mag'][0], sensor_data['right_mag'][1], sensor_data['right_mag'][2])
ax.set_title('right mag')
plt.show()
结果是下图。我如何正确地格式化这些?
1条答案
按热度按时间vuv7lop31#
在
add_subplot
中如何使用行、列和索引有问题。我希望这里有帮助:第一个数字是行和列的(总)数量,第三个数字是“索引”,i。即从1..6(=行 * 列)。
它看起来是这样的:
但要完全回答这个问题,需要做些什么:
然后可以使用轴(ax1..6)如,例如、