0
0
Matplotlibdata~30 mins

Font size guidelines in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Font size guidelines
📖 Scenario: You are creating a simple bar chart to show sales data for a small store. You want to make sure the text on the chart is easy to read by setting appropriate font sizes for the title, axis labels, and tick labels.
🎯 Goal: Build a bar chart using matplotlib with custom font sizes for the title, x-axis label, y-axis label, and tick labels.
📋 What You'll Learn
Create a list of sales data for 4 products
Set font sizes for the chart title, x-axis label, y-axis label, and tick labels
Use matplotlib.pyplot to plot the bar chart
Display the chart with the specified font sizes
💡 Why This Matters
🌍 Real World
In real life, clear and readable charts help people understand data quickly, such as sales reports or survey results.
💼 Career
Data scientists and analysts often customize chart fonts to make reports and presentations more professional and accessible.
Progress0 / 4 steps
1
Create sales data
Create a list called sales with these exact values: 150, 200, 300, 250.
Matplotlib
Need a hint?

Use square brackets [] to create a list and separate values with commas.

2
Set font size variables
Create four variables to set font sizes: title_font_size to 16, x_label_font_size to 12, y_label_font_size to 12, and tick_font_size to 10.
Matplotlib
Need a hint?

Assign the numbers directly to the variable names using =.

3
Plot bar chart with font sizes
Import matplotlib.pyplot as plt. Create a list products with 'A', 'B', 'C', 'D'. Use plt.bar() to plot products on x-axis and sales on y-axis. Set the chart title to 'Sales by Product' with font size title_font_size. Set x-axis label to 'Product' with font size x_label_font_size. Set y-axis label to 'Sales' with font size y_label_font_size. Set tick label font size to tick_font_size using plt.xticks() and plt.yticks().
Matplotlib
Need a hint?

Use fontsize parameter to set font sizes in plt.title(), plt.xlabel(), plt.ylabel(), and plt.xticks(), plt.yticks().

4
Display the chart
Use plt.show() to display the bar chart with the font sizes applied.
Matplotlib
Need a hint?

Call plt.show() to display the plot window.