Search code examples
pythoncsvmatplotlibmultilineforex

Plot multiple line from csv file in python


I have a CSV file like this containing 8 currency indices.

RCS M5 288.csv

How can I plot these indices in one figure? If possible, can I have buttons to add currencies one by one?


Solution

  • Lets go through your requirements step-by-step:

    1. You need to read the CSV file. This can be done in several ways. I've majorly used both pandas and the csv libraries. You can use any of them or some other method if you find any.
    2. You need to plot all of them in the same picture. For this you can use a directory by the name matplotlib. You'll have to import a specific section of it as the library is huge to be imported while running. I suggest you use the following code:
      import matplotlib.pyplot as plt.

      In the imported section you can use a function called
      plt.plot()

      which can take in any number of arrays and plot them.
    3. Coming to your last requirement, you might want to refer to tkinter or any other such python GUI libraries.