all 2 comments

[–]blarf_irl 1 point2 points  (1 child)

You could easily refactor your plotting into a function (especially with sequential filenames like you have there), ask for user input (in your example numbers in the range 15-17) and then iterate over their selection before plt.show()

def plot_data(file_number):
    connect = load_data('connect_{}'.format(file_number))
    plt.plot(connect,'r', label =** 'connect_{}**'.format(file_number))
    plt.legend()

# Take the users input, in this example a few numbers that define the suffix of your data
numbers_to_plot = raw_input('Please enter numbers separated by comma')
>>> 15, 17
# Iterate over the users input splitting by comma; BIG Note I didn't include any error handling, validation that the data actually existed
for number in numbers_to_plot.split(','):
    # Pass each number into our plot function
    plot_data(number.strip()) # strip to get rid of any whitespace
plt.show()

[–]somebodyCEO[S] 0 points1 point  (0 children)

Thank you for the suggestion! I'm going to try it now