1

matplotlib 中有一个尚未修复的已知错误。

考虑这个代码片段。通过反转 y 轴,刻度消失并且 z 轴上的填充发生变化。

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

ax.set_xlim3d(0,1)
ax.set_ylim3d(0,1)
ax.set_ylim3d(1,0)
plt.show()

在此期间有人有解决方法吗?

谢谢!

4

1 回答 1

0

Maybe you can bring your data to [0,1] range (or [yourmin, yourmax] where yourmin < yourmax) and then just change axis ticks labels:


import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import Axes3D
    import numpy as np

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')

    ax.set_xlim3d(0,1)
    ax.set_ylim3d(0,1)
    # setting ticks positions
    ax.set_xticks(np.arange(0,1.1,0.2))
    ax.set_yticks(np.arange(0,1.1,0.2))
    # setting ticks labels
    ax.set_xticklabels(np.arange(1, -.1,-.2,).round(1))
    ax.set_yticklabels(np.arange(1, -.1,-.2,).round(1))

    plt.show()

于 2012-12-10T04:45:27.530 回答