Python Forum
Python Matplotlib: Create chart for every 4 columns in Excel file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Matplotlib: Create chart for every 4 columns in Excel file

I want to loop through every 4 columns in an Excel file and create line charts in a pdf file.

There is no upload function for me to show my Excel file as sample.

Basically create 4 lines in a single chart for Column B-E, another 4 lines in a 2nd single chart for Column F-I.
Column A will be the date, or x-axis in the charts

The excel file could have many set of 4 columns, so the code must loop through all of them and create all the charts in a single pdf file (1 chart per page).

How do I do so?

THank you
go to and search for the packages that you will need to complete.
for excel, visit:

There are also published guides available (which may or may not be biased) for example, for excel

openpyxl is a good choice:

For PDF, there are again many packages available

Report Lab:
is praised as being an excellent choice (my experience is limited, so refrain from adding my opinion)

I want to use Mathplotlib for it. Basically, it should loop through every 4 columns in my Excel file and create a separate graph for every 4 column

Every 4 columns will be the Revenue, Cost, Wage and Profit for a firm. The graph for each firm will have the 4 lines for Revenue, Cost, Wage and Profit

Thank you

Possibly Related Threads…
Thread Author Replies Views Last Post
  Create a 2-channel numpy file from two cvs file containing a 9x9 matrix silvialecc 1 124 Today, 07:59 AM
Last Post: Gribouillis
  rows from sql query need to write to a file as columns sjcsvatt 6 249 Oct-09-2021, 12:45 AM
Last Post: snippsat
  Problem in saving .xlsm (excel) file using pandas dataframe in python shantanu97 2 440 Aug-29-2021, 12:39 PM
Last Post: snippsat
  Verification of an excel file saleenahohn 2 327 Jul-09-2021, 06:56 AM
Last Post: Larz60+
  Read and write active Excel file euras 4 634 Jun-29-2021, 11:16 PM
Last Post: Pedroski55
  Open an excel file Newbie1114 1 658 Jun-16-2021, 09:11 PM
Last Post: Gribouillis
  [Solved] Using readlines to read data file and sum columns Laplace12 4 631 Jun-16-2021, 12:46 PM
Last Post: Laplace12
  Create ZIP file not working using ZipFile? korenron 1 483 Jun-13-2021, 04:15 PM
Last Post: korenron
  How to save Matplot chart to temp file? Morkus 2 846 Jun-12-2021, 10:52 AM
Last Post: Morkus
  problem with pyinstaller to create an executable file atlass218 0 636 May-15-2021, 11:01 AM
Last Post: atlass218

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020