5
The problem is that when you read the data, even though they are numbers in the file, they are strings, so Plot interprets them as if they were classes and not numerical values. To solve this just castear to integer values.
import matplotlib.pyplot as plt
data = """1 2
2 4
3 1"""
data = data.split('\n')
x = [row.split(' ')[0] for row in data]
y = [row.split(' ')[1] for row in data]
# casteia os valores para inteiro
x = [int(element) for element in x]
y = [int(element) for element in y]
plt.plot(x, y)
plt.show()
What is the content of
text.txt
?– Woss
1 2 2 4 3 1 -----
– eepaulo
Put this in the properly formatted question, please.
– Woss