Draw a horizontal bar chart with Matplotlib Read Courses Practice Improve Improve Improve Like Article Like Save Article Save Report issue Report Matplotlib is the standard python library for creating visualizations in Python. Pyplot is a module of Matplotlib library which is used to plot graphs and charts and also make changes in them. In this article, we are going to see how to draw a horizontal bar chart with Matplotlib. Creating a vertical bar chart Approach: Importing matplotlib.pyplot as pltCreating list x for discrete values on x-axisCreating list y consisting only numeric data for discrete values on y-axisCalling plt.bar() function with parameters x,y as plt.bar(x,y)Setting x_label() and y_label()Setting title() for our bar chartCalling plt.show() for visualizing our chart Below is the implementation: Python3 import matplotlib.pyplot as plt x=['one', 'two', 'three', 'four', 'five'] # giving the values against# each value at x axisy=[5, 24, 35, 67, 12] plt.bar(x, y) # setting x-label as pen soldplt.xlabel("pen sold") # setting y_label as priceplt.ylabel("price") plt.title(" Vertical bar graph")plt.show() Output: Creating a horizontal bar chart Approach: Importing matplotlib.pyplot as pltCreating list y for discrete values on y-axisCreating list x consisting only numeric data for discrete values on x-axisCalling plt.barh() function with parameters y,x as plt.barh(y,x)Setting x_label() and y_label()Setting title() for our bar chartCalling plt.show() for visualizing our chart Below is the implementation: Python3 import matplotlib.pyplot as plty=['one', 'two', 'three', 'four', 'five'] # getting values against each value of yx=[5,24,35,67,12] plt.barh(y, x) # setting label of y-axisplt.ylabel("pen sold") # setting label of x-axisplt.xlabel("price") plt.title("Horizontal bar graph")plt.show() Output: Last Updated : 25 Aug, 2021 Like Article Save Article Previous Bar Plot in Matplotlib Next Create a stacked bar plot in Matplotlib Share your thoughts in the comments Add Your Comment Please Login to comment...