[英]Eliminating scientific notation on vertical axis of 3d plot (Python)
如何消除 3d 繪圖垂直軸上的科學記數法,並將其替換為整數? 例如,我想要2002
而不是0.0+2.002e3
我的示例腳本如下:
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])
嘗試使用ax.zaxis.set_major_formatter
和ax.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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.