Skip to main content

data visualize(bar chart)

from matplotlib import pyplot as plt

movies = ["Annie Hall", "Ben-Hur", "Casablanca", "Gandhi", "West Side Story"]
num_oscars = [5, 11, 3, 8, 10]


#bar chart
# bars are by default width 0.8, so we'll add 0.1 to the left coordinates
# so that each bar is centered
#xs = [i + 0.1 for i, _ in enumerate(movies)]
# plot bars with left x-coordinates [xs], heights [num_oscars]




plt.bar(movies,num_oscars,color='red')
#label x-axis with movie names at bar centers
#plt.xticks([i + 0.5 for i, _ in enumerate(movies)], movies)
plt.show()

fig:-


Comments

Popular posts from this blog

Connect POSTgreSQL with Django

  First install all necessary step  $ sudo apt-get install python-pip python-dev libpq-dev postgresql postgresql-contrib Second $ sudo su - postgres $ psql Create User name with password  $ CREATE USER user_name WITH PASSWORD ' password ';   Create New Database $ CREATE DATABASE database_name WITH OWNER user_name ; Give permission  $ GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO user_name ; Update settings.py  DATABASES = { ' default ' : { ' ENGINE ' : ' django.db.backends.postgresql_psycopg2 ' , ' NAME ' : 'database_name ' , ' USER ' : ' user_name ' , ' PASSWORD ' : ' password' , ' HOST ' : ' localhost ' , ' PORT ' : ' 5432 ' , } }  Then, python3 manage.py migrate and finally create super user python3 man age.py createsuperuser