You are previewing Learning Python Data Visualization.
O'Reilly logo
Learning Python Data Visualization

Book Description

Master how to build dynamic HTML5-ready SVG charts using Python and the pygal library

In Detail

The best applications use data and present it in a meaningful, easy-to-understand way. Packed with sample code and tutorials, this book will walk you through installing common charts, graphics, and utility libraries for the Python programming language.

Firstly you will discover how to install and reference libraries in Visual Studio or Eclipse. We will then go on to build simple graphics and charts that allow you to generate HTML5-ready SVG charts and graphs, along with testing and validating your data sources. We will also cover parsing data from the Web and offline sources, and building a Python charting application using dynamic data. Lastly, we will review other popular tools and frameworks used to create charts and import/export chart data. By the end of this book, you will be able to represent complex sets of data using Python.

What You Will Learn

  • Build different types of Python charts and graphs
  • Master how to build Python graphics libraries
  • Test and validate your data sources
  • Explore common Python libraries for charts and graphics
  • Build charts using dynamic data from offline and online sources
  • Use CSS to modify embedded SVG images in HTML pages
  • Install and write Python code on Windows, Mac, or Linux
  • Discover how to install and reference libraries in Visual Studio or Eclipse
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

    Table of Contents

    1. Learning Python Data Visualization
      1. Table of Contents
      2. Learning Python Data Visualization
      3. Credits
      4. About the Author
      5. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Setting Up Your Development Environment
        1. Introduction
        2. Setting up Python on Windows
        3. Installation
        4. Exploring the Python installation in Windows
        5. Python editors
        6. Setting up Python on Mac OS X
        7. Setting up Python on Ubuntu
        8. Summary
      9. 2. Python Refresher
        1. Python basics
          1. Importing modules and libraries
          2. Input and output
          3. Generating an image
        2. Creating SVG graphics using svgwrite
          1. For Windows users using VSPT
          2. For Eclipse or other editors on Windows
          3. For Eclipse on Mac and Linux
        3. Summary
      10. 3. Getting Started with pygal
        1. Why use pygal?
          1. Installing pygal using pip
          2. Installing pygal using Python Tools for Visual Studio
          3. Building a line chart
        2. Stacked line charts
        3. Simple bar charts
        4. Stacked bar charts
        5. Horizontal bar charts
        6. XY charts
        7. Scatter plots
        8. DateY charts
        9. Summary
      11. 4. Advanced Charts
        1. Pie charts
          1. Stacked pie charts
        2. Radar charts
        3. Box plots
        4. Dot charts
        5. Funnel charts
        6. Gauge charts
        7. Pyramid charts
        8. Worldmap charts
        9. Summary
      12. 5. Tweaking pygal
        1. Country charts
        2. Parameters
          1. Legend at the bottom
          2. Legend settings
        3. Label settings
        4. Chart title settings
        5. Displaying no data
        6. pygal themes
        7. Summary
      13. 6. Importing Dynamic Data
        1. Pulling data from the Web
        2. The XML refresher
        3. RSS and the ATOM
        4. Understanding HTTP
          1. Using HTTP in Python
        5. Parsing XML in Python with HTTP
        6. About JSON
        7. Parsing JSON in Python with HTTP
        8. About JSONP
        9. JSONP with Python
        10. Summary
      14. 7. Putting It All Together
        1. Chart usage for a blog
          1. Getting our data in order
          2. Converting date strings to dates
          3. Using strptime
          4. Saving the output as a counted array
            1. Counting the array
        2. Python modules
          1. Building the main method
        3. Modifying our RSS to return values
          1. Building our chart module
          2. Building a portable configuration for our chart
          3. Setting up our chart for data
          4. Configuring our main function to pass data
        4. Project improvements
        5. Summary
      15. 8. Further Resources
        1. The matplotlib library
          1. Installing the matplotlib library
          2. matplotlib's library download page
          3. Creating simple matplotlib charts
        2. Plotly
        3. Pyvot
        4. Summary
      16. A. References and Resources
        1. Links for help and support
        2. Charting libraries
        3. Editors and IDEs for Python
        4. Other libraries and Python alternative shells
      17. Index