Calculate the Deception Factor
Advanced · Predict the output · from Data Visualization: Choose the Right Chart and Tell a Story
From the lesson: Data Visualization: Choose the Right Chart and Tell a Story
A chart that looks pretty but tells the wrong story is worse than no chart at all. In 1986, NASA engineers showed managers a chart arguing that cold temperatures could damage the Space Shuttle Challenger's O-ring seals. The chart was so poorly designed that the managers couldn't see the pattern.
Read the lessonWhat will this code print? It calculates how much a truncated y-axis exaggerates the visual difference between two bars.
bar_a = 95
bar_b = 100
# Honest chart (y starts at 0)
honest_ratio = bar_b / bar_a
# Truncated chart (y starts at 90)
truncated_ratio = (bar_b - 90) / (bar_a - 90)
print(round(honest_ratio, 2))
print(round(truncated_ratio, 2))
More Data Visualization exercises
All Python exercises · 50 practice problems · Data Science & Machine Learning quiz