I am working on a project and the final step is to plot the data that I acquired. I am trying to do that with matplotlib and python. The data is stored is a file. The data is stored line by line and the format is the following: "a b" where a is the value that is supposed to be on the x-axis and from line to line just increases by 1. On the other hand, b is supposed to be on the y-axis and that one grows exponentially from line to line. But when I plot the graph I just see a line instead of an exponential function. The values on the y-axis instead of increasing by the same amount from tick to tick, they assume the value of b for each point in the graph, therefore The the graph is a line and not an exponential function. How can I fix this? This is an image of the graph: graph. This is the code:

import matplotlib.pyplot as plt

file = open("../Data/data.txt","r")

data = []

#Extract data from file

for line in file:
    data.append(line.split(" "))

#-----------------------------------    

data_a = []
data_b = []

#Splitting the data into 2 arrays, 1 for each axis
for DATA in data:
    data_a.append(DATA[0])
    data_b.append(DATA[1])
#----------------------------------------------
plt.plot(data_a,data_b,"ro")

plt.show()

0 Answers