Home > Net >  How can I eliminate the headers from my graph (using python and pandas to graph a CSV file)?
How can I eliminate the headers from my graph (using python and pandas to graph a CSV file)?

Time:04-19

I am trying to graph data from a CSV file, however, I keep getting headers as if I were graphing to different things. I want to remove this (the orange line on the top left corner). Actually if I could remove the whole thing it would be better.

My code is:

import pandas as pd
import matplotlib.pyplot as plt


plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

headers = ['Espectro del plasma de Ag con energía de 30mJ', "tiempo (microsegundos) vs Voltaje (v)", " "]

df = pd.read_csv('TEK0000.csv', names=headers)

ax = df.set_index('Espectro del plasma de Ag con energía de 30mJ').plot()
ax.set_xlabel('tiempo (microsegundos)')
ax.set_ylabel('voltaje (V)')
plt.show()

Graph

CodePudding user response:

Try this:

headers = ['Espectro del plasma de Ag con energía de 30mJ', "tiempo (microsegundos) vs Voltaje (v)"]

df = pd.read_csv('TEK0000.csv', names=headers, usecols=[0,1])

Or:

ax = df.set_index('Espectro del plasma de Ag con energía de 30mJ')['tiempo (microsegundos) vs Voltaje (v)'].plot()
  • Related