Axis scales (linear, log) with matplotlib
📖 Scenario: You are analyzing sales data that grows exponentially. You want to see how the sales look on a normal scale and on a logarithmic scale to better understand the growth pattern.
🎯 Goal: Create a simple line plot of sales data using matplotlib. First, plot the data with a linear scale on the y-axis. Then, change the y-axis scale to logarithmic to compare the views.
📋 What You'll Learn
Create a list called
sales with the values: 10, 100, 1000, 10000, 100000Create a list called
months with the values: 1, 2, 3, 4, 5Create a variable called
y_scale and set it to the string 'linear'Use matplotlib to plot
months vs sales with the y-axis scale set to y_scaleChange the value of
y_scale to 'log' and plot the same data againPrint the plots so the output shows both linear and logarithmic scale plots
💡 Why This Matters
🌍 Real World
Scientists and business analysts often use logarithmic scales to better understand data that grows exponentially or covers a wide range.
💼 Career
Knowing how to change axis scales in plots is important for data visualization roles and helps communicate insights clearly.
Progress0 / 4 steps