Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to draw a bar graph in python


import numpy as np
import matplotlib.pyplot as plt
 
  
# creating the dataset
data = {'C':20, 'C++':15, 'Java':30,
        'Python':35}
courses = list(data.keys())
values = list(data.values())
  
fig = plt.figure(figsize = (10, 5))
 
# creating the bar plot
plt.bar(courses, values, color ='maroon',
        width = 0.4)
 
plt.xlabel("Courses offered")
plt.ylabel("No. of students enrolled")
plt.title("Students enrolled in different courses")
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: remove empty strings from list python 
Python :: python clear screen windows and linux 
Python :: how to remove numbers from string in python dataframe 
Python :: how to get a row from a dataframe in python 
Python :: pandas change column name from a dictionary 
Python :: reverse string in python 
Python :: pyodbc ms access 
Python :: python df round values 
Python :: remove item from list if it exists python 
Python :: urlencode python 
Python :: get last file in directory python 
Python :: how to plotting horizontal bar on matplotlib 
Python :: termcolor python 
Python :: python get nth letter of alphabet 
Python :: how to remove first letter of a string python 
Python :: python run as service windows 
Python :: take input in 2d list in python 
Python :: pd merge on multiple columns 
Python :: Tkinter button icons 
Python :: python 1 to 01 
Python :: psyche 
Python :: django form widget 
Python :: install python 3.9 centos8 
Python :: two loop type python 
Python :: how to open sound file in python 
Python :: spread operator python 
Python :: install nltk in python 
Python :: new in python 
Python :: python close browser 
Python :: label encoding 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =