Uncategorized

Reading arrays from txt file in python to plot a graph


I’m new to python and want to plot a graph using data stored in arrays on a txt file…

content in the txt file ar just the arrays… nothing else.. exemple:

arrays.txt

[0, 1, 10, 5, 40, 1, 70] [12, 54, 6, 11, 1, 0, 50]

just that… two or more arrays with the brackets and nothing else..

I want to read each array and load them into variables to plot a graph in python using matplotlib

import matplotlib.pyplot as plt

# import arrays from file as variables
a = [array1]
b = [array2]

plt.plot(a)
plt.plot(b)
plt.show()

The only thing I need is how to read the arrays from the txt and load them into variables to plot them later…

I’ve searched a lot but also find too many ways to do a lot of things in python which is good but also overwhelming



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *