donkirkby / donkirkby/live-py-plugin

Use difference threshold in matplotlib lessons

Open
#211 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
302
Forks
63
Avg merge
6h 50m
Merged PRs (30d)
2

Description

# What I did
Wrote a matplotlib lesson, and tried to solve it. The difference view looked completely black, but the "Solved!" message didn't appear. The problem turned out to be a difference in the y scale at about the fifth decimal place. I can't see the difference, but maybe there's some difference in the anti-aliasing or something.

Here's a simple example of the same problem:

""" :lesson goal file: example_goal.py
"""
from matplotlib import pyplot as plt

plt.plot([1, -1, .3])
plt.ylim(-1.1, 1.1)
plt.show()

And here's the goal file where the y scale is slightly different.

from matplotlib import pyplot as plt

plt.plot([1, -1, .3])
plt.ylim(-1.09999, 1.09999)
plt.show()

# What I wanted to happen
The code that detects a solution should have some kind of "close enough" threshold. If the colours are off by a tiny bit, then it can still be a solution.

It also might be helpful to keep the difference view aligned with one of the regular views. Maybe two versions of the difference view? Monochrome and faded colour?

The difference view can even be a little difficult to see on some real differences. For example, a lesson where you have to turn off the legend's border box. It was very difficult to see the grey border box in the black difference display. As well as adding a minimum difference that counts for failure, it might be worth doubling the brightness of the differences you display. Another option would be to make the lines thicker in the lesson code, just so the differences are easier to see. However, I think I'd rather have more standard graphs than making everything really thick.

# My environment
Describe the versions of everything you were using:
* PyCharm 2018.3.1
* Ubuntu 18.04
* Python 2.7.15

Contributor guide

Open the contributing guide

Research direction

Start with the example_goal.py lesson and reproduce the mismatch between the two plots. Locate the code that detects a solved lesson and renders the difference view, then determine how a close-enough threshold and clearer difference display should be evaluated. Done means the provided near-identical plots are accepted while meaningful differences, such as the legend border, remain visible and detectable.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.