Read text file and plot by using Pandas and matplotlib.pyplot in Python

Here is a sample code.

import pandas as pd
import matplotlib.pyplot as plt


filename = 'a.txt'

data = pd.read_csv(filename, sep='\t', header=None)
plt.plot(data[0],data[1])
plt.xlabel('Raman shift (cm-1)', size=14)
plt.ylabel('Intensity', size=14)
plt.xlim(1000,3000)
plt.savefig('Raman.png', transparent=True)
plt.show()


This is the link on details of read_csv of pandas. (https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html)

This is the link on details of matplotlib.pyplot. (https://matplotlib.org/api/_as_gen/matplotlib.pyplot.html)

Thanks,

JF

댓글

이 블로그의 인기 게시물

미국 포닥, 한국으로 돌아가는 이유? (Why do postdoc go back to Korea?)

미국 포닥 월급 생활비, 일리노이 텍사스 포닥 (Illinois, Texas Postdoc Living Cost)

J1 미국 포닥, 미국 영주권 (EB2) 신청 및 승인 후기 (첫번째. J1 비자)