python 繪圖設定 模板

來源:互聯網
上載者:User

標籤:span   ace   round   格式   idt   插入   設定   nbsp   mit   

存個模板

# -*- coding: utf-8 -*-"""Created on Fri Sep 29 17:17:31 2017@author: HBB"""import numpy as npimport matplotlib.pyplot as pltd =  np.loadtxt(‘d1.txt‘,delimiter = ‘,‘)  # txt檔案的載入                                  # 繪圖命令的啟動 設定線型顏色,線寬,類型,          plt.plot(d,‘g-‘,linewidth=2.0,label="banding",alpha=0.9)                                # 繪畫命令  不是 plt.figure# ‘g-o‘==color=’green‘,linestyle=‘-‘,marker=‘o‘# plt.plot(a,a*1.5,color="green",linewidth=3.0,linestyle="-",marker=‘o‘,,markerfacecolor=‘blue‘,markersize=20,label="COS",alpha=0.9) ‘‘‘plot()函數的使用plot(x,y,format_string,**kwargs)x:x軸資料,列表或數組,可選y:y軸資料,列表或數組format_string :控制曲線的格式字串,可選      由顏色字元,風格字元(曲線實虛)和標記字元組成  (配圖說明)          **kwargs:第二組或者更多(x,y,format_string)‘‘‘              # 座標軸的相關設定# plt.axis([100,600,5000,35000])            # 尺度範圍的設定plt.xlim(100,600)                           # x軸的設定plt.ylim(5000,35000)                        # y軸的設定        ax=plt.gca()                               # 引入座標軸ax.spines["right"].set_color("none")       # 隱藏右側座標軸ax.spines["top"].set_color("none")         # 隱藏上面的座標軸ax.spines["left"].set_position(("data",100))     # 控制位置ax.spines["bottom"].set_position(("data",5000))  # 控制位置# 座標軸的刻度顯示位置ax.xaxis.set_ticks_position("bottom")ax.yaxis.set_ticks_position("left")# 設定刻度數字大小和邊框for lable in ax.get_xticklabels()+ax.get_yticklabels():    lable.set_fontsize(16)                     # 刻度大小    lable.set_bbox(dict(facecolor="white",edgecolor="None",alpha=0.2)) # 設定刻度主次刻度大小,,不會# 插入文本# 標題plt.title("XPS",fontsize=20)                                        # 標題# 座標軸plt.xlabel(‘能量‘,fontproperties=‘SimHei‘,fontsize=20)              # 中文顯示plt.ylabel(‘Intensity‘,fontsize=20)# 在任意地方插入文本plt.text(210,20000,"TiO2",fontsize=15)         # 帶箭頭嘚文本plt.annotate(‘C 1s‘,fontsize=16,xy=(430,25000),xytext=(350,30000),arrowprops=dict(facecolor=‘black‘,shrink=3.0,width=1))plt.annotate("Ru 3d",fontsize=16,xy=(500,33000),xycoords="data",xytext=(+10,+20),textcoords="offset points",arrowprops=dict(arrowstyle="->",connectionstyle="arc3,rad=0.2"))# 其他功能# 劃線plt.plot([300,300],[0,35000],"y",linewidth=3.0,linestyle="--")# [300,300],[0,35000] 應該是相當於[x1,x2],[y1,y2] 所以點應該是(x1,y1)和(x2,y2)# ‘y‘ 線的顏色  # 也可以寫成‘y--‘  不用寫 linestyle="--"# 圖例plt.legend(loc="upper left")# 網格線# plt.grid(True)# 填充 # plt.fill_between(x,np.abs(x)<0.5,c,c>0.5,color="green",alpha=0.5)   #搞不通這個範圍???# 映像的儲存# plt.savefig(‘test‘,dpi=600)              plt.show()                                 # 映像的顯示

 

python 繪圖設定 模板

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.