I'm trying to plot spectrum contains ~11 000 points, so my program hangs (past my code line), below my code. How can I fix it?
import matplotlib.pyplot as plt
try:
spectrum_file = open('external_data/spectrum.txt', 'r')
spectrum_data = spectrum_file.read()
print('Spectrum has imported successfully')
except:
print('Error of importing spectrum')
try:
spectrum_data = spectrum_data.split('\n')
x = [row.split('\t')[0] for row in spectrum_data] # ['1', '2', ... , '11 000']
y = [row.split('\t')[1] for row in spectrum_data]
print('Spectrum data has separated successfully')
except:
print('Error of separating the spectrum data')
plt.plot(x, y, label='Spectrum')
plt.show()

plotlyspectrum_file.read()), rather iterate directly though it. This will use less RAM.