# plotchecker
[](https://travis-ci.org/jhamrick/plotchecker)
[](http://codecov.io/github/jhamrick/plotchecker?branch=master)
[](http://plotchecker.readthedocs.org/en/latest/?badge=latest)
A set of utilities for checking and grading matplotlib plots. **Please note that `plotchecker` is only compatible with Python 3, and not legacy Python 2**. Documentation is available on [Read The Docs](https://plotchecker.readthedocs.org/).
## Installation
To install `plotchecker`:
```
pip3 install plotchecker
```
## Background
The inspiration for this library comes from including plotting exercises in programming assignments. Often, there are multiple possible ways to solve a problem; for example, if students are asked to create a "scatter plot", the following are all valid methods of doing so:
```python
# Method 1
plt.plot(x, y, 'o')
# Method 2
plt.scatter(x, y)
# Method 3
for i in range(len(x)):
plt.plot(x[i], y[i], 'o')
# Method 4
for i in range(len(x)):
plt.scatter(x[i], y[i])
```
Unfortunately, each of the above approaches also creates a different underlying representation of the data in matplotlib. Method 1 creates a single Line object; Method 2 creates a single Collection; Method 3 creates *n* Line objects, where *n* is the number of points; and Method 4 creates *n* Collection objects. Testing for all of these different edge cases is a huge burden on instructors.
While some of the above options are certainly better than others in terms of simplicity and performance, it doesn't seem quite fair to ask students to create their plots in a very specific way when all we've asked them for is a scatter plot. If they look pretty much identical visually, why isn't it a valid approach?
Enter `plotchecker`, which aims to abstract away from these differences and expose a simple interface for instructors to check students' plots. All that is necessary is access to the `Axes` object, and then you can write a common set of tests for plots independent of how they were created.
```python
from plotchecker import ScatterPlotChecker
axis = plt.gca()
pc = ScatterPlotChecker(axis)
pc.assert_x_data_equal(x)
pc.assert_y_data_equal(y)
...
```
Please see the [Examples.ipynb](Examples.ipynb) notebook for futher examples on how `plotchecker` can be used.
Caveats: there are *many* ways that plots can be created in matplotlib. `plotchecker` almost certainly misses some of the edge cases. If you find any, please submit a bug report (or even better, a PR!).
[](https://travis-ci.org/jhamrick/plotchecker)
[](http://codecov.io/github/jhamrick/plotchecker?branch=master)
[](http://plotchecker.readthedocs.org/en/latest/?badge=latest)
A set of utilities for checking and grading matplotlib plots. **Please note that `plotchecker` is only compatible with Python 3, and not legacy Python 2**. Documentation is available on [Read The Docs](https://plotchecker.readthedocs.org/).
## Installation
To install `plotchecker`:
```
pip3 install plotchecker
```
## Background
The inspiration for this library comes from including plotting exercises in programming assignments. Often, there are multiple possible ways to solve a problem; for example, if students are asked to create a "scatter plot", the following are all valid methods of doing so:
```python
# Method 1
plt.plot(x, y, 'o')
# Method 2
plt.scatter(x, y)
# Method 3
for i in range(len(x)):
plt.plot(x[i], y[i], 'o')
# Method 4
for i in range(len(x)):
plt.scatter(x[i], y[i])
```
Unfortunately, each of the above approaches also creates a different underlying representation of the data in matplotlib. Method 1 creates a single Line object; Method 2 creates a single Collection; Method 3 creates *n* Line objects, where *n* is the number of points; and Method 4 creates *n* Collection objects. Testing for all of these different edge cases is a huge burden on instructors.
While some of the above options are certainly better than others in terms of simplicity and performance, it doesn't seem quite fair to ask students to create their plots in a very specific way when all we've asked them for is a scatter plot. If they look pretty much identical visually, why isn't it a valid approach?
Enter `plotchecker`, which aims to abstract away from these differences and expose a simple interface for instructors to check students' plots. All that is necessary is access to the `Axes` object, and then you can write a common set of tests for plots independent of how they were created.
```python
from plotchecker import ScatterPlotChecker
axis = plt.gca()
pc = ScatterPlotChecker(axis)
pc.assert_x_data_equal(x)
pc.assert_y_data_equal(y)
...
```
Please see the [Examples.ipynb](Examples.ipynb) notebook for futher examples on how `plotchecker` can be used.
Caveats: there are *many* ways that plots can be created in matplotlib. `plotchecker` almost certainly misses some of the edge cases. If you find any, please submit a bug report (or even better, a PR!).
Metadata
Release files for plotchecker 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| plotchecker-0.2.0.tar.gz | 75.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| plotchecker-0.2.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 191.1 kB
Release files / plotchecker-0.2.0.tar.gz
| Download URL | plotchecker-0.2.0.tar.gz |
|---|---|
| Size | 75.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18bc08ad2900365beb5e54a96d77927feae2e12efc1484b1ea0d0ccc491f971c
|
|
BLAKE2b-256 checksum How to use checksums |
2809f4a15d3ebc6f7b9d514c33279ecc884928b1a4c976583a9e713a955269c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / plotchecker-0.2.0-py2.py3-none-any.whl
| Download URL | plotchecker-0.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 116.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
01c5d2a7e549553e463729777c365ff6204742cc86f0bc2a5cbbb276da10744c
|
|
BLAKE2b-256 checksum How to use checksums |
300f99ad6ee7e2ff85c36b1359db9f1718b47f9228a6bebe9ee161f236c6b7af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |