国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

修改python plot折線圖的坐標軸刻度方法

2020-01-04 13:50:10
字體:
供稿:網(wǎng)友

修改python plot折線圖的坐標軸刻度,這里修改為整數(shù):

python,plot,折線圖,坐標軸,刻度

代碼如下:

from matplotlib import pyplot as pltimport matplotlib.ticker as tickerimport numpy as npdef std_plot(): overall_std = [34.369, 21.366, 16.516, 11.151] max_std = [36.769, 21.794, 14.390, 4.684] plt.figure() plt.plot(overall_std, label='average_std') plt.plot(max_std, label='max_std') plt.legend() plt.xlabel('window') plt.ylabel('std') plt.xticks(range(len(max_std))) # plt.gca().xaxis.set_major_formatter(ticker.FormatStrFormatter('%1.1f')) plt.show()std_plot()

可以發(fā)現(xiàn),通過上面的方法可以自定義x軸的刻度顯示為其他樣式,比如根據(jù)時間顯示。只需要修改為:

plt.xticks(pd.date_range(‘2014-09-01','2014-09-30'),rotation=90)#設(shè)置時間標簽顯示格式

如果希望保留小數(shù)點后一位,可以這樣:

python,plot,折線圖,坐標軸,刻度

from matplotlib import pyplot as pltimport matplotlib.ticker as tickerimport numpy as npdef std_plot(): overall_std = [34.369, 21.366, 16.516, 11.151] max_std = [36.769, 21.794, 14.390, 4.684] plt.figure() plt.plot(overall_std, label='average_std') plt.plot(max_std, label='max_std') plt.legend() plt.xlabel('window') plt.ylabel('std') # plt.xticks(range(len(max_std))) plt.gca().xaxis.set_major_formatter(ticker.FormatStrFormatter('%1.1f')) plt.show()std_plot()

以上這篇修改python plot折線圖的坐標軸刻度方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持VEVB武林網(wǎng)。


注:相關(guān)教程知識閱讀請移步到python教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 沽源县| 莱阳市| 武夷山市| 广南县| 赤壁市| 肥城市| 尚义县| 衡阳市| 彭山县| 志丹县| 罗平县| 米林县| 岗巴县| 普格县| 万州区| 沈阳市| 奎屯市| 深州市| 安宁市| 福州市| 车险| 华容县| 苏尼特左旗| 白沙| 崇明县| 内丘县| 庆云县| 鸡泽县| 松溪县| 湄潭县| 乌什县| 易门县| 神农架林区| 河曲县| 阿拉善左旗| 报价| 邵东县| 浦东新区| 两当县| 得荣县| 诸暨市|