Concept Flow - Axis scales (linear, log)
Start: Prepare data
Choose scale type
Set axis scale
Plot data
→Show plot
End
This flow shows preparing data, choosing axis scale (linear or log), setting it, plotting, and displaying the plot.
import matplotlib.pyplot as plt x = [1, 10, 100, 1000] y = [1, 2, 3, 4] plt.plot(x, y) plt.xscale('log') plt.show()
| Step | Action | Variable/Parameter | Value/Effect | Output/Plot State |
|---|---|---|---|---|
| 1 | Import matplotlib.pyplot | plt | module loaded | No plot yet |
| 2 | Define x data | x | [1, 10, 100, 1000] | No plot yet |
| 3 | Define y data | y | [1, 2, 3, 4] | No plot yet |
| 4 | Plot data | plt.plot(x, y) | Line plot created | Plot with linear axes |
| 5 | Set x-axis scale | plt.xscale('log') | x-axis scale set to logarithmic | Plot x-axis changes to log scale |
| 6 | Show plot | plt.show() | Plot displayed | Visible plot with log-scaled x-axis |
| Variable | Start | After Step 2 | After Step 3 | After Step 4 | After Step 5 | Final |
|---|---|---|---|---|---|---|
| x | undefined | [1, 10, 100, 1000] | [1, 10, 100, 1000] | [1, 10, 100, 1000] | [1, 10, 100, 1000] | [1, 10, 100, 1000] |
| y | undefined | undefined | [1, 2, 3, 4] | [1, 2, 3, 4] | [1, 2, 3, 4] | [1, 2, 3, 4] |
| x-axis scale | linear (default) | linear | linear | linear | logarithmic | logarithmic |
| plot state | none | none | none | line plot with linear axes | line plot with log x-axis | displayed plot with log x-axis |
Axis scales control how data is spaced on plot axes.
Linear scale spaces data evenly.
Log scale spaces data by powers of 10.
Use plt.xscale('log') or plt.yscale('log') to set log scale.
Log scale cannot handle zero or negative values.
Changing scale affects how data points appear on the plot.