Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

bar plot matplotlib

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
langs = ['C', 'C++', 'Java', 'Python', 'PHP']
students = [23,17,35,29,12]
ax.bar(langs,students)
plt.show()
Comment

how to plotting bar on matplotlib

import matplotlib.pyplot as plt 

data = [5., 25., 50., 20.]
plt.bar(range(len(data)),data)
plt.show()

// to set the thickness of a bar, we can set 'width'
// plt.bar(range(len(data)), data, width = 1.)
Comment

matplotlib bar chart

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
# the format of the bar() method is: 
# plt.bar(x_value, y_value, color, width_of_bars_inches)
plt.bar(courses, values, color ='maroon',
        width = 0.4)
# x-axis label
plt.xlabel("Courses offered")
# y-axis label
plt.ylabel("No. of students enrolled")
# Title of the figure
plt.title("Students enrolled in different courses")
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: create or append dataframe to csv python 
Python :: pygame get keypress code 
Python :: how to make an empty variable in python 
Python :: number of days in a month python 
Python :: how to install pyinstaller 
Python :: split at the second occurrence of the element python 
Python :: discord.py send image from url 
Python :: how to setup django ionos hostig 
Python :: how to power in python 
Python :: np append row 
Python :: python arguments 
Python :: how to make python open a program/desktop app 
Python :: how to convert .ui file to .py 
Python :: tkinter entry focus 
Python :: get name of month python 
Python :: builtwith python 
Python :: how to take input for list in one line in python 
Python :: median of array python 
Python :: python get zip file size 
Python :: legend matplotlib 
Python :: np array to list 
Python :: python assert is not null 
Python :: python array methods 
Python :: slicing in python listing 
Python :: pandas print tabulate no index 
Python :: python cli click 
Python :: function for detecting outliers in python 
Python :: smtplib send caleneder email 
Python :: count occurrence in array python 
Python :: use django taggit in template 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =