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

首頁 > 編程 > Python > 正文

修改python plot折線圖的坐標(biāo)軸刻度方法

2020-02-16 00:06:42
字體:
供稿:網(wǎng)友

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

python plot折線圖的坐標(biāo)軸刻度

代碼如下:

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è)置時間標(biāo)簽顯示格式

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

python plot折線圖的坐標(biāo)軸刻度

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折線圖的坐標(biāo)軸刻度方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持武林站長站。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 北京市| 株洲县| 罗源县| 太保市| 吕梁市| 玉田县| 金塔县| 济宁市| 盘山县| 独山县| 通榆县| 淮南市| 常宁市| 湖口县| 厦门市| 西青区| 木里| 梁河县| 电白县| 禹州市| 北碚区| 桃江县| 凌源市| 平顶山市| 盐城市| 隆安县| 民丰县| 大化| 房山区| 沙河市| 酉阳| 普格县| 西林县| 乐安县| 古交市| 南华县| 上栗县| 日照市| 来凤县| 尉犁县| 昂仁县|