【问题标题】:Eliminating scientific notation on vertical axis of 3d plot (Python)消除 3d 绘图垂直轴上的科学记数法(Python)
【发布时间】:2016-08-19 00:43:36
【问题描述】:

如何消除 3d 绘图垂直轴上的科学记数法,并将其替换为整数?例如,不是0.0+2.002e3,而是2002 我的示例脚本如下:

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

yearvec = [2002, 2003, 2004]
plt.close('all')
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_xlim3d(0, 250)
ax.set_ylim3d(0, 250)
ax.set_zlim3d(yearvec[0], yearvec[-1])

【问题讨论】:

    标签: python python-2.7 matplotlib mplot3d z-axis


    【解决方案1】:

    尝试使用ax.zaxis.set_major_formatterax.zaxis.set_major_locator

    import numpy as np
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import axes3d
    from matplotlib.ticker import FormatStrFormatter, MultipleLocator
    
    yearvec = [2002, 2003, 2004, 2005]
    plt.close('all')
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    ax.set_xlim3d(0, 250)
    ax.set_ylim3d(0, 250)
    ax.set_zlim3d(yearvec[0], yearvec[-1])
    
    majorLocator   = MultipleLocator(1)
    ax.zaxis.set_major_locator(majorLocator)
    zFormatter = FormatStrFormatter('%d')
    ax.zaxis.set_major_formatter(zFormatter)
    

    这就是你想要的?

    【讨论】:

    • 完美!这正是我正在寻找的。谢谢!
    猜你喜欢
    • 2011-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-23
    • 2014-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多