#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
📈 FREE · 10 CHART TYPES

Matplotlib Chart Code Generator: Paste Data, Get Chart Code

Pick a chart, paste a few rows or point at a CSV, and get clean Matplotlib code that saves a sharp picture.

  • 📊 Grouped and stacked bars
  • 🥧 Pie and donut
  • 🎨 Styles and colours

How to use the Matplotlib Chart Code Generator

  1. 1. Choose a chartLine, area, bar, horizontal bar, grouped, stacked, pie, donut, scatter or histogram.
  2. 2. Add dataPaste a small table (labels then values) or name a CSV and its columns.
  3. 3. Style and copySet titles, colours, style, size and file name, then copy or download the script.

What the code includes

The script uses the recommended fig, ax = plt.subplots() style. It sets the title and axis labels, removes the top and right borders, adds light grid lines and, for bars, value labels with ax.bar_label. Grouped bars are offset with NumPy, stacked bars carry a running bottom, and pie and donut charts keep a round shape. A legend appears when there's more than one series. Finally fig.tight_layout() and savefig(..., dpi=150, bbox_inches="tight") save it without clipped labels. Pasted data is written into the script; a CSV source reads with pandas.

Worked example

The default is a grouped bar chart of monthly enrolments for Python and Data Analytics from April to September (6 labels × 2 series), with the orange-and-navy palette. The result is a 28-line script that saves chart.png. The page also shows a quick sketch so you can check the layout before running it.

How we checked it

  • All 10 chart types were generated with pasted data and with a CSV source, across four palettes and five styles.
  • All 20 scripts ran with Matplotlib and saved a picture.
  • bar_label needs Matplotlib 3.4 or later; the seaborn style name needs Matplotlib 3.6 or later.
  • Values are written into the script as plain numbers, so ₹ symbols and commas in pasted data are removed first.

Choosing a chart

Use a line chart for change over time, bars to compare categories, grouped bars to compare two series side by side, and stacked bars to show parts of a total. Keep pie and donut charts to a handful of slices, use scatter to show a relationship between two numbers, and use a histogram to see how values are spread.

Frequently asked questions

Where does the chart appear?

plt.show() opens it in a window (or below the cell in Jupyter), and it's also saved to the file name you chose.

Can I use my Excel data?

Copy the cells from Excel and paste them into the data box. Pasted tabs work as well as commas.

Is the Matplotlib chart code generator free?

Yes. You can open the Matplotlib chart code generator, load files and set every option without signing up. When you generate code for the first time, we ask once for your name and WhatsApp number; after that it, and every other Uncodemy tool, opens straight away.

More free tools

See all free tools