Challenge - 5 Problems
Log and Symlog Scale Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of log scale plot ticks
What will be the y-axis tick labels when using
plt.yscale('log') on data ranging from 1 to 1000?Matplotlib
import matplotlib.pyplot as plt import numpy as np x = np.linspace(1, 10, 10) y = np.linspace(1, 1000, 10) plt.plot(x, y) plt.yscale('log') ticks = plt.gca().get_yticks() print(ticks)
Attempts:
2 left
💡 Hint
Think about how log scale places ticks at powers of 10.
✗ Incorrect
Log scale places ticks at powers of 10 by default, so ticks include 1, 10, 100, 1000, etc.
❓ data_output
intermediate2:00remaining
Effect of symlog scale on negative values
Given the data
y = [-100, -10, -1, 0, 1, 10, 100], what will be the y-axis limits after applying plt.yscale('symlog', linthresh=1)?Matplotlib
import matplotlib.pyplot as plt import numpy as np y = np.array([-100, -10, -1, 0, 1, 10, 100]) plt.plot(y) plt.yscale('symlog', linthresh=1) lims = plt.gca().get_ylim() print(lims)
Attempts:
2 left
💡 Hint
Symlog scale extends limits slightly beyond data range to show linear region.
✗ Incorrect
Symlog scale with linthresh=1 extends limits beyond data range to include linear region around zero, so limits are slightly larger than min and max data values.
❓ visualization
advanced3:00remaining
Identify the plot with symlog scale
Which plot correctly uses
symlog scale to handle data with negative and positive values near zero?Matplotlib
import matplotlib.pyplot as plt import numpy as np x = np.linspace(-10, 10, 400) y = x**3 plt.figure(figsize=(8, 4)) plt.subplot(1, 2, 1) plt.plot(x, y) plt.yscale('log') plt.title('Log scale') plt.subplot(1, 2, 2) plt.plot(x, y) plt.yscale('symlog', linthresh=100) plt.title('Symlog scale') plt.tight_layout() plt.show()
Attempts:
2 left
💡 Hint
Symlog scale can show negative values near zero, log scale cannot.
✗ Incorrect
The right plot uses symlog scale which handles negative and positive values near zero by combining linear and log scales. The left plot uses log scale which cannot handle negative values.
🧠 Conceptual
advanced1:30remaining
Why use symlog scale instead of log scale?
Which reason best explains why you would choose
symlog scale over log scale in a plot?Attempts:
2 left
💡 Hint
Log scale cannot show zero or negative values.
✗ Incorrect
Symlog scale allows plotting data with negative, zero, and positive values by combining linear scale near zero and log scale away from zero.
🔧 Debug
expert2:30remaining
Identify the error in symlog scale usage
What error will this code produce and why?
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-10, 10, 100)
y = x**2
plt.plot(x, y)
plt.yscale('symlog', linthresh=-1)
plt.show()Matplotlib
import matplotlib.pyplot as plt import numpy as np x = np.linspace(-10, 10, 100) y = x**2 plt.plot(x, y) plt.yscale('symlog', linthresh=-1) plt.show()
Attempts:
2 left
💡 Hint
Check the parameter requirements for linthresh in symlog scale.
✗ Incorrect
The linthresh parameter must be a positive number. Negative linthresh causes ValueError.