Turn an Excel chart into matplotlib
Rebuilding an Excel chart in Python means reading the sheet with pandas.read_excel and drawing the same series with matplotlib. You get a script that reproduces the figure from the data, plus full control over fonts, sizes and export formats.
When to use it
- A chart lives in a spreadsheet and needs to go into a paper or report.
- The data is updated regularly and the chart should be regenerated, not redrawn by hand.
Ask for it in pltchat
Upload your file and type something like:
"recreate the Excel clustered column chart from sheet 'Results', same colours"
pltchat writes the loader and the plot for your columns, runs it in your browser and shows you the code.
The matplotlib code
Self-contained with example data; swap in pd.read_csv(...) or
pd.read_excel(...) for your own file.
import pandas as pd
import matplotlib.pyplot as plt
# With your file: df = pd.read_excel("results.xlsx", sheet_name="Results")
df = pd.DataFrame({"Month": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
"2023": [12, 15, 14, 18, 21, 24],
"2024": [14, 17, 19, 22, 24, 29]})
excel_colors = ["#4472C4", "#ED7D31"] # Office default palette
ax = df.plot.bar(x="Month", color=excel_colors, width=0.7, rot=0,
figsize=(6.4, 4))
ax.set_ylabel("Orders (k)")
ax.set_xlabel("")
ax.yaxis.grid(True, color="#D9D9D9")
ax.set_axisbelow(True)
ax.spines[["top", "right", "left"]].set_visible(False)
ax.legend(frameon=False, loc="upper center", bbox_to_anchor=(0.5, -0.08), ncol=2)
plt.tight_layout()
plt.show()
Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.