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?)

미국 포닥 - 비지팅 포닥 VS 풀펀딩 포닥 (Visiting Scholar VS Postdoctoral Fellow)

미국 포닥 직위, 타이틀, 명칭? - Visiting Scholar, Postdoctoral Fellow, Research Associate, Research Scientist, Research Professor