Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Simple Bar Chart | Bar Charts
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Visualization in Python with matplotlib

bookSimple Bar Chart

Welcome to the second section! You've done great work so far! In this section, we will consider another common type of chart - this is a bar chart.

The concept for creating a bar chart is the same as for line plot: initialize Axes and Figure objects using the .subplots() method and then apply .bar() function to Axes object. The first argument (x) of the function is the x coordinates of the bar, the second (height) - the heights of the bars. For example, let's visualize some abstract subject grades.

123456789101112131415
# Import library import matplotlib.pyplot as plt # Create data for chart subjects = ['Math', 'Literature', 'History', 'Physics', 'Arts'] grades = [95, 76, 83, 92, 68] # Create Axes and Figure objects fig, ax = plt.subplots() # Initialize bar chart ax.bar(subjects, grades) # Display the plot plt.show()
copy

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 1

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Suggested prompts:

Still meg spørsmål om dette emnet

Oppsummer dette kapittelet

Vis eksempler fra virkeligheten

bookSimple Bar Chart

Sveip for å vise menyen

Welcome to the second section! You've done great work so far! In this section, we will consider another common type of chart - this is a bar chart.

The concept for creating a bar chart is the same as for line plot: initialize Axes and Figure objects using the .subplots() method and then apply .bar() function to Axes object. The first argument (x) of the function is the x coordinates of the bar, the second (height) - the heights of the bars. For example, let's visualize some abstract subject grades.

123456789101112131415
# Import library import matplotlib.pyplot as plt # Create data for chart subjects = ['Math', 'Literature', 'History', 'Physics', 'Arts'] grades = [95, 76, 83, 92, 68] # Create Axes and Figure objects fig, ax = plt.subplots() # Initialize bar chart ax.bar(subjects, grades) # Display the plot plt.show()
copy

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 1
some-alt