Book Image

The Data Visualization Workshop

By : Mario Döbler, Tim Großmann
Book Image

The Data Visualization Workshop

By: Mario Döbler, Tim Großmann

Overview of this book

Do you want to transform data into captivating images? Do you want to make it easy for your audience to process and understand the patterns, trends, and relationships hidden within your data? The Data Visualization Workshop will guide you through the world of data visualization and help you to unlock simple secrets for transforming data into meaningful visuals with the help of exciting exercises and activities. Starting with an introduction to data visualization, this book shows you how to first prepare raw data for visualization using NumPy and pandas operations. As you progress, you’ll use plotting techniques, such as comparison and distribution, to identify relationships and similarities between datasets. You’ll then work through practical exercises to simplify the process of creating visualizations using Python plotting libraries such as Matplotlib and Seaborn. If you’ve ever wondered how popular companies like Uber and Airbnb use geoplotlib for geographical visualizations, this book has got you covered, helping you analyze and understand the process effectively. Finally, you’ll use the Bokeh library to create dynamic visualizations that can be integrated into any web page. By the end of this workshop, you’ll have learned how to present engaging mission-critical insights by creating impactful visualizations with real-world data.
Table of Contents (9 chapters)
Preface
7
7. Combining What We Have Learned

Images

If you want to include images in your visualizations or work with image data, Matplotlib offers several functions for you. In this section, we will show you how to load, save, and plot images with Matplotlib.

Note

The images that are used in this section are sourced from https://unsplash.com/.

Basic Image Operations

The following are the basic operations for designing an image.

Loading Images

If you encounter image formats that are not supported by Matplotlib, we recommend using the Pillow library to load the image. In Matplotlib, loading images is part of the image submodule. We use the alias mpimg for the submodule, as follows:

import matplotlib.image as mpimg

The mpimg.imread(fname) reads an image and returns it as a numpy.array object. For grayscale images, the returned array has a shape (height, width), for RGB images (height, width, 3), and for RGBA images (height, width, 4). The array values range from 0 to 255.

We can also load the image in...