I am trying to make a graph from some data I took.
I have managed to write a script that will give me the two graphs I am looking for.
import numpy
import ROOT
from ROOT import TGraph
from array import array
filename = “testdata.txt”
x1, y1, z1, a1 = numpy.loadtxt(filename, unpack=True)
x = array(“d”, x1)
y = array(“d”, y1)
z = array(“d”, z1)
c1=ROOT.TCanvas(“c1”, “”, 700, 500)
gr = TGraph(len(x), x,y)
gr.SetTitle(“237 typeD”)
gr.GetXaxis().SetTitle(“Voltage”)
gr.GetYaxis().SetTitle(“Current”)
gr.Draw()
c1.SaveAs(“graph5.png”)
c2=ROOT.TCanvas(“c2”, “”, 700, 500)
gr1 = TGraph(len(x), x,z)
gr1.SetTitle(“2002 typeD”)
gr1.GetXaxis().SetTitle(“Voltage”)
gr1.GetYaxis().SetTitle(“Current”)
gr1.Draw()
c2.SaveAs(“graph6.png”)
This works fine.
The problem I am having, is that the data file I took isn’t so neat as the one I used here.
I took the right values from the real data file, and put them neatly into three columns into another text file, testdata.txt.
I want to be able to graph these same numbers from my original data file.
That is, how do I read only certain parts of the file:
Skip the headers a few rows down, and then certain columns only.
Is there a way to do this? Is it completely different that what I have here?
Thanks!