Skip to Content
Hands-On Data Structures and Algorithms with Python - Second Edition
book

Hands-On Data Structures and Algorithms with Python - Second Edition

by Dr. Basant Agarwal, Benjamin Baka, David Julian
October 2018
Beginner to intermediate
398 pages
11h 1m
English
Packt Publishing
Content preview from Hands-On Data Structures and Algorithms with Python - Second Edition

Multiple bar charts

In trying to visualize data, stacking a number of bars enables one to further understand how one piece of data or variable varies compared to another:

    data = [             [8., 57., 22., 10.],             [16., 7., 32., 40.],           ]     import numpy as np     x_values = np.arange(4)     plt.bar(x_values + 0.00, data[0], color='r', width=0.30)     plt.bar(x_values + 0.30, data[1], color='y', width=0.30)     plt.show() 

The y values for the first batch of data are [8., 57., 22., 10.]. The second batch is [16., 7., 32., 40.]. When the bars are plotted, 8 and 16 will occupy the same x position, side by side.

x_values = np.arange(4) generates the array with values [0, 1, 2, 3]. The first set of bars are drawn first at position x_values + 0.30. Thus, the first x values ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Data Structures and Algorithms with Python - Third Edition

Hands-On Data Structures and Algorithms with Python - Third Edition

Dr. Basant Agarwal
Data Structures & Algorithms in Python

Data Structures & Algorithms in Python

John Canning, Alan Broder, Robert Lafore
Data Structures and Algorithms in Python

Data Structures and Algorithms in Python

Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser

Publisher Resources

ISBN: 9781788995573Supplemental Content