Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Bar Plots | Gaining Insights with Data Visualization
Gaining Insights with Data Visualization

book
Bar Plots

A bar plot, also known as a bar chart or bar graph, is a graphical representation of data using bars of different heights. It is used to display quantitative data, with the length of each bar representing the magnitude of the data.

Bar plots are particularly useful for displaying and comparing values across different categories or groups. They allow for clear visualization of large datasets, facilitating comparisons and highlighting patterns and trends. Additionally, bar plots can help in understanding the relationships between different variables by using various visual modifications such as colors and patterns.

Compito

Swipe to start coding

  1. Import the numpy library with the np alias.
  2. Use the appropriate function to create a bar plot based on bars and height.
  3. Display the resulting plot.

Soluzione

# Import the numpy library
import numpy as np
import matplotlib.pyplot as plt

# Creating a dataset
height = [3, 12, 5, 18, 45]
bars = ('A', 'B', 'C', 'D', 'E')
y_pos = np.arange(len(bars))

# Create a bar plot
plt.bar(y_pos, height)

# Setting names on the x-axis
plt.xticks(y_pos, bars)

# Display the resulting plot
plt.show()

Mark tasks as Completed
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 4
AVAILABLE TO ULTIMATE ONLY
some-alt