Skip to Content
Python Data Structures and Algorithms
book

Python Data Structures and Algorithms

by Benjamin Baka
May 2017
Intermediate to advanced
310 pages
8h 5m
English
Packt Publishing
Content preview from Python Data Structures and Algorithms

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 with 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 will ...

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

Data Structures and Algorithms in Python

Data Structures and Algorithms in Python

Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Hands-On Data Structures and Algorithms with Python - Second Edition

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

Dr. Basant Agarwal, Benjamin Baka, David Julian
Data Structures & Algorithms in Python

Data Structures & Algorithms in Python

John Canning, Alan Broder, Robert Lafore

Publisher Resources

ISBN: 9781786467355Supplemental Content