
The bar graph can be modified by running the set of codes below.
#BAR PLOT MAGICPLOT STUDENT CODE#
The result of the code ran above can be viewed below.Ī horizontal bar graph showing the highest goal scorers in the premier league 2019/20 mid-season.īoth the bar graph and the horizontal bar graphs can be modified to look more beautiful. plt.show( ) is used to generate the graph using the previous commands. plt.title(“Highest goal scorers in the Premier league 2019–20 by mid-season”) is used to make a title for the graph. plt.xlabel(“Players”) and plt.ylabel(“Goal Scored”) are used to label the x-axis and y-axis respectively. Plt.bar(“Player”, “Stat”, data = df_goal, color = “blue”) is used to signify that a bar graph wants to be plotted using the Player column as the x-axis, the Stat column as the y-axis, the df_goal dataset is to be used and the color of the bars are blue.

plt.bar("Player", "Stat", data = df_goal, color = "blue") plt.xlabel("Players") plt.ylabel("Goal Scored") plt.title("Highest goal scorers in the Premier league 2019-20 by mid-season") plt.show() The bar graph is built after installing the package by running the set of codes below.

# Import data visualization packages import matplotlib.pyplot as plt %matplotlib inline Creating a bar graph

Matplotlib is used in python programming language as a plotting library. Below is a set of codes for importing the bar graph. In order to run codes that will generate a bar graph, a data visualization package called matplotlib is imported. Top five goal scorers in the premier league 2019/20 midseason Import the Data Visualization packages
