Learn Python with Talk Python's 270 hours of courses

Python Data Visualization - Where To Start?

Episode #384, published Tue, Oct 4, 2022, recorded Wed, Sep 28, 2022

Do you struggle to know where to start in the wide range of Python's visualization frameworks? Not sure when to use Plotly vs. Matplotlib vs. Altair? Then this episode is for you. We have Chris Moffitt, a Talk Python course author and founder of Practical Business Python, back on the show to discuss getting started with Python's data visualization frameworks.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guest Introduction and Background

Chris Moffitt is a seasoned data enthusiast and Python developer with a strong background in business-focused analytics. He works in the medical device industry, leveraging Python to build forecasting tools and analyze data beyond the limitations of Excel. Chris also runs the blog Practical Business Python, where he shares tips, tutorials, and insights on Python’s data stack for real-world use cases. He’s previously appeared on Talk Python to Me discussing ways to leverage Python instead of Excel for data analysis, and in this episode, Chris returns to share practical tips and guidance on Python data visualization.

What to Know If You're New to Python

If you’re just getting started with Python and want to get the most out of this discussion on data visualization, here are a few quick pointers:

  • Basic Python Syntax: Familiarize yourself with importing libraries, calling functions, and using objects.
  • Working in Notebooks: Experiment with Jupyter or VS Code notebooks to see quick plots via df.plot() or matplotlib.pyplot.
  • Installing Packages: Use pip or conda to install visualization libraries like Matplotlib, Seaborn, Plotly, or Altair for your projects.
  • Pandas 101: Understanding Pandas data frames and how to load, explore, and clean data sets the stage for good visualizations.

Key Points and Takeaways

  1. Finding the Right Visualization Library Many newcomers struggle with the breadth of Python’s plotting libraries—Matplotlib, Seaborn, Plotly, Altair, and more. Chris emphasizes that choosing the right tool often comes down to whether you need quick static plots (Matplotlib, Seaborn), deep interactivity (Plotly, Bokeh), or a declarative approach (Altair).
  2. Why Matplotlib Is Still Relevant Matplotlib is considered the foundation of modern Python data visualization. Even though it can appear low-level and verbose, learning its object-oriented approach helps you understand the internals of many other libraries. Matplotlib offers unparalleled customization for publication-quality charts and supports saving plots in numerous formats (PNG, SVG, PDF).
  3. Pandas Plotting for Quick Insights Pandas has a built-in .plot() API (powered by Matplotlib) for a quick look at your data. It requires little Python knowledge, making it a great option when you just need a histogram or a simple line chart. For more specific visualizations, you can still tap into the underlying Matplotlib API or switch to libraries like Seaborn or Plotly.
  4. Seaborn for Statistical Plots Seaborn builds on top of Matplotlib and specializes in statistical data visualization with concise syntax and sleek styling. It offers advanced plots like pair plots, box plots, heatmaps, and more, often just a single function call away. This makes it ideal for exploring relationships, distributions, and correlations in data.
  5. Altair for a Declarative Approach Altair (based on Vega-Lite) focuses on a “declarative” style, where you specify the relationship of your data rather than manually building each plot element. This style can lead to more readable code and easy interactive features like custom tooltips, hover effects, and selection-based highlighting.
  6. Plotly for Interactivity and Specialized Charts Plotly offers powerful, interactive visualizations out of the box with minimal setup. Tree maps, sunburst charts, and map-based plots can all be created with just a few lines of code. Because of its JavaScript foundation, you can zoom, pan, hover, and slice data right in the notebook or your web browser.
  7. Streamlit for Quick Dashboards When you need fast, interactive dashboards with minimal overhead, Streamlit is a top choice. It builds on a procedural script style: you write Python top-to-bottom, define interactive elements like sliders or checkboxes, and Streamlit handles the web app logic for you—no JavaScript required.
  8. Dash for Rich, Production-Grade Apps Dash (from Plotly) is another powerful framework to build fully interactive dashboards, often integrating with real-time data. It requires a bit more code and a deeper understanding of callbacks, layout, and deployment but can result in polished, enterprise-ready applications.
  9. Iterative Development and Customization A recurring theme is that visualizations start simple and evolve. You might create a quick Altair or Seaborn plot, then iterate by adding color encoding, custom tooltips, or by refining the style. Each small change, like rotating the x-axis labels or adjusting tick formatters, can substantially clarify your message.
  10. Practical Business Applications Chris shared how he uses Python data visualization in a business context, such as forecasting models and operational dashboards. He emphasized that Python solutions are repeatable and can handle larger datasets compared to doing the same work in Excel. This underscores how even a small Python automation script can save hours of manual labor each week.

Interesting Quotes and Stories

"What does the Python tool say?" – Chris describes how colleagues often refer to his forecasting script as “the Python tool,” highlighting how Python-based solutions can become a go-to system for data insight in non-software organizations.

“Sometimes I'll Google a question and find my own article.” – Chris admits writing up solutions so future-him has a reference when encountering the same data pitfalls or debugging moments, a reminder of the power of sharing knowledge.

Key Definitions and Terms

  • Declarative Visualization: A style where you describe what you want to plot rather than how to plot it step-by-step (e.g., Altair).
  • Faceting: Splitting data into multiple panels based on a categorical variable (often used in Seaborn with FacetGrid or Altair’s row/column encoding).
  • JSON-based Visuals: Altair transforms data into JSON under the hood for Vega-Lite, enabling easy interactive features in the browser.
  • Tree Map / Sunburst: Specialized chart types for hierarchical data, supported by Plotly.

Learning Resources

Below are some additional places to solidify your understanding and broaden your Python skills:

Overall Takeaway

Python’s data visualization ecosystem might seem overwhelming, but each library—Matplotlib, Seaborn, Plotly, Altair—brings unique strengths. Whether you need simple quick plots, deeply interactive charts, or a streamlined dashboard experience, Python can do it all. Embrace iterative workflows: start with a straightforward plot, then refine your visualization to suit your audience, data size, and deployment needs. Ultimately, Python’s adaptability for business use-cases ensures you can move beyond Excel to create both beautiful and maintainable visual solutions.

Links from the show

Chris on Twitter: @chris1610
Python Data Visualization course: talkpython.fm
10 tips to move from Excel to Python episode: talkpython.fm
Escaping Excel Hell with Python and Pandas episode: talkpython.fm
PB Python: pbpython.com
matplotlib: matplotlib.org
Seaborn example: seaborn.pydata.org
Altair: altair-viz.github.io
Plotly sunburst: plotly.com
Plotly treemap: plotly.com
streamlit: streamlit.io
Dash: dash.gallery
Streamlit Talk Python episode: talkpython.fm
splink package: github.com
redframes package: github.com
Edward Tufte book: edwardtufte.com
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm

--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy

Talk Python's Mastodon Michael Kennedy's Mastodon