In this section, we use the dataset cargame.csv to demonstrate how to create basic graphical displays in Python. Below is the scenario for the data:
A toy company has four types of vehicles for sale: car, truck, racer, and taxi. To judge the quality of the different types of vehicles, a team records the following characteristics: the user’s gender (Gender), the type of a car in the trial, the distance vehicle is pulled back (Pull Distance), the distance the car goes after pulling it back (Distance) and the time for each trial in seconds (Time).
First, we use the module Pandas to open and read the data.
We then prepare the data for Visualization.
Note: The y-axis can also be changed to represent the relative frequency. Can you figure out how to do this?
In the following example, we study the distribution of average distance that each type of vehicles covered and create a horizontal bar chart by using the Python function plt.barh().
In the following example, we study the stacked bar chart for the total distance grouped by two variables: Name of Car and Distance. Here we use the plot() function in the module Pandas. In the legend method, we use two parameters: loc and ncol.
Tutorials for learning how to create Python bar charts can be found at matplotlib, PythonSpot, pyplot, Plotly, pandas, and seaborn (You need to download the library first, but there are lots of good features. Highly recommended for professional data visualization!).
501 E. High Street
Oxford, OH 45056
1601 University Blvd.
Hamilton, OH 45011
4200 N. University Blvd.
Middletown, OH 45042
7847 VOA Park Dr.
(Corner of VOA Park Dr. and Cox Rd.)
West Chester, OH 45069
Chateau de Differdange
1, Impasse du Chateau, L-4524 Differdange
Grand Duchy of Luxembourg
217-222 MacMillan Hall
501 E. Spring St.
Oxford, OH 45056, USA