-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First pass at using stylesheets * Bug fixes and readme update * Updated the examples, removed dark mode examples, and fixed some bugs * Fixed some examples * Added Prompt font install to github actions * Ran black * Added a james-themed plot to the README * Attempting to fix GHA and updated testing matrix * Needed quotes around Python versions in GHA * Fixed docstrings for new styles * Maybe init file is needed in styles directory * Removed colors return from setStyle * Adding init to styles dir did not help GHA problems * Added all stylesheets to python install * Needed another option in setup file * Trying to debug GHA * Temporarily change testing matrix for debugging * Trying more complete stylesheet path specification * I think I fixed it, restored GHA script * Numpy 1.18 does not support Python 3.9 and 3.10, made it a newer version * Numpy 1.20 is not new enough, updating to 1.21 * Added Prompt font install to read the docs * Used the wrong yaml command for RTD font install * Switched to using matplotlib built in style sheet management * New function to get list of colors * Fixed formatting * Trying one more thing before giving up on RTD * I give up, RTD sux * Fixed docstring * Typo * Address changes from Neil * Removed default figure size and changed default font size * Removed hardcoded colors * Add generated docs to gitignore * Changed figure size in parula contours example * Ran black * Tweaking Doumont stylesheet, not done yet * Adding simple Doumont example * Trying to install Prompt better * Changed Prompt font install for RTD * Testing older numpy * Update Doumont styles * Replace default formatting example with gaussian plot * Add some comments to the gaussian plotting script * Tweak dark doumont style, update example png's * Fix readme image widths * Can we make Github actions update the png's for us? * Try again * Trying to fix conditional * Trying to get around permissions issue * Try a different pushing action * Try another push action * please work * Maybe this works * I hate GHA * Bump RTD dependencies * Try again * Improve readme * Rename styles example * Cleanup GHA * Update example figures * Add style names to style demo plots * Use svg images for example docs * Update example figures * Make sphinx gallery work properly * `black -l 120 .` * Update example figures * Remove old pngs * Friendship with png is over, svg is my best friend now * Update example figures * need to move files to auto_examples * Update example figures * Missed one svg * Update example figures * Ensure only GHA can push images to the repo * Update example figures * Add reference images and test against them * Add missing ref images * Improve dependency installation * typo * Trying to improve image comparison test * Make image test a little more forgiving * Even more forgiving * Super forgiving * backtracking * bisection * Try again with other matplotlib/numpy/pillow versions * So close * Please work * OK, back to 0.9 * Tweaked James * Added color cycle demo for each style * Fixed james gaussian and added refs * Alphabetize styles when returned * Fixed capitalization * Store odiff results as artifact to download * Upload artifact even if previous step fails * Make image comparison non-binding * Update ref nested_pie_chart.png * Update readme image paths * Comment out reference image upload * Add note on backwards incompatible changes to the readme Co-authored-by: Alasdair Gray <[email protected]> Co-authored-by: A-CGray <[email protected]>
- Loading branch information
1 parent
325af36
commit 4b669c3
Showing
54 changed files
with
730 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,53 +7,74 @@ | |
[![PyPI - Downloads](https://img.shields.io/pypi/dm/niceplots)](https://pypi.org/project/niceplots/) | ||
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) | ||
|
||
<img src="https://raw.githubusercontent.com/mdolab/niceplots/main/examples/ParulaContours.png" width="62.22%" /> <img src="https://raw.githubusercontent.com/mdolab/niceplots/main/examples/optProb-shaded.png" width="35%" /> | ||
<img src="https://raw.githubusercontent.com/mdolab/niceplots/main/examples/bar_chart.png" width="47.65%" /> <img src="https://raw.githubusercontent.com/mdolab/niceplots/main/examples/niceplotsPulseResponse.png" width="49.5%" /> | ||
<img src="https://mdolab-niceplots.readthedocs-hosted.com/en/latest/_images/sphx_glr_plot_parula_contours_001.svg" width="61%" /> <img src="https://mdolab-niceplots.readthedocs-hosted.com/en/latest/_images/sphx_glr_plot_opt_prob_002.svg" width="38.2%" /> | ||
<img src="https://mdolab-niceplots.readthedocs-hosted.com/en/latest/_images/sphx_glr_plot_bar_chart_001.svg" width="61%" /> <img src="https://mdolab-niceplots.readthedocs-hosted.com/en/latest/_images/sphx_glr_plot_style_demo_004.svg" width="38.2%" /> | ||
|
||
<!-- https://mdolab-niceplots.readthedocs-hosted.com/en/latest/_images/ --> | ||
|
||
### How do I install? | ||
## How do I install? | ||
|
||
Niceplots can be pip installed directly from PyPI | ||
NicePlots can be pip installed directly from PyPI | ||
|
||
```shell | ||
pip install niceplots | ||
``` | ||
|
||
#### If you want to make changes | ||
### If you want to make changes | ||
|
||
* Clone this repository, then enter the folder in the command line terminal. | ||
* Enter `pip install -e .` within the `niceplots` folder. | ||
|
||
#### Font installation (optional) | ||
### Font installation (optional) | ||
|
||
Niceplots will try and use the [computer modern bright](https://tug.org/FontCatalogue/computermodernbright/) font for the best looking plots so be sure to install it as a system font if you want to recreate the style of the plots above. | ||
Otherwise, niceplots will still work but revert back to the matplotlib default sans-serif font, DejaVu Sans. | ||
NicePlots styles use fonts that do not ship with most operating systems, so you'll need to install them separately. | ||
If they are not installed, matplotlib will revert back to its default sans-serif font, DejaVu Sans. | ||
|
||
The font used by each style is as follows: | ||
- doumont-light (default niceplots): CMU Bright | ||
- doumont-dark: CMU Bright | ||
- james-dark: Prompt | ||
- james-light: Prompt | ||
|
||
Install the fonts on your system and then delete Matplotlib's font cache, which is located in `~/.cache/matplotlib` by default on most operating systems. | ||
Matplotlib will rebuild the font cache next time it is run and (hopefully) find the new fonts. | ||
|
||
#### CMU Bright (doumont-light and doumont-dark) | ||
|
||
The computer modern bright font can be downloaded from [this link](https://tug.org/FontCatalogue/computermodernbright/). | ||
Alternatively, on Ubuntu, the font can be installed with the following commands: | ||
|
||
To install the font on Ubuntu, run the following commands: | ||
``` | ||
sudo apt-get update | ||
sudo apt-get install fonts-cmu | ||
``` | ||
Arch linux users can get the font by installing the `otf-cm-unicode` package from AUR. | ||
|
||
If niceplots doesn't recognize the font, it might be necessary to delete Matplotlib's font cache file from its location on your computer, likely in `~/.cache/matplotlib` | ||
#### Prompt (james-dark and james-light) | ||
|
||
The Prompt font can be download from [Google Fonts](https://fonts.google.com/specimen/Prompt). | ||
|
||
## How do I get set up? | ||
|
||
* `import matplotlib.pyplot as plt` and `import niceplots` at the top of a file where you would like to use any function defined in this package. | ||
* Use `plt.style.use(niceplots.get_style())` to set some defaults for nice-looking plots. You can also try passing different styles to `get_style()`, such as NicePlots' `"james-dark"` or any of matplotlib's styles (see the function's documentation for a full list of available NicePlots styles). | ||
* Take advantage of NicePlots' helper functions, including (but not limited to) `adjust_spines`, `horiz_bar`, and `plot_nested_pie`, which are all documented in the [examples gallery](https://mdolab-niceplots.readthedocs-hosted.com/en/latest/auto_examples/index.html). | ||
* Admire your beautiful data. | ||
|
||
### How do I get set up? | ||
## Do you have docs? | ||
|
||
* Use `import niceplots` at the top of a file where you would like to use any function defined in this package. | ||
* Use `niceplots.setRCParams()` to set some matplotlib defaults for nice looking plots. Set `dark_mode=True` and `set_background_color=True` to make plots with a dark background. | ||
* Use `niceplots.All()` after all the plot commands to apply the niceplot standards on the figure. | ||
* To use the Matlab colormap "parula", execute `from niceplots import parula` then use `parula.parula_map` as your colormap within your plotting script. See the contour plot example code for an example of this. | ||
Sort of, you can find our examples gallery and API documentation [here](https://mdolab-niceplots.readthedocs-hosted.com/en/latest) | ||
|
||
### Do you have docs? | ||
## Help, my old NicePlots code doesn't work anymore! | ||
|
||
Sort of, you can find our examples gallery and api documentation [here](https://mdolab-niceplots.readthedocs-hosted.com/en/latest) | ||
We made a couple of changes to the API in version 2.0.0, most of them can be fixed with a simple find and replace. | ||
Check the [release notes](https://github.com/mdolab/niceplots/releases/tag/v2.0.0) for more details. | ||
|
||
### Contribution guidelines | ||
## Contribution guidelines | ||
|
||
* Make any changes you see fit. Please fork your own version and submit a pull request. | ||
|
||
### Who do I talk to? | ||
## Who do I talk to? | ||
|
||
* Alasdair Gray, [email protected] | ||
* Eytan Adler, [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
sphinx_mdolab_theme | ||
sphinx-gallery | ||
matplotlib>=3.4 | ||
matplotlib>=3.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# This script compares the images generated by the example scripts to a set of reference images | ||
|
||
test_passed=true # Kepp track of whether any tests fail | ||
|
||
# First check that there aren't any images produced by the examples that don't have a reference image | ||
for f in *.png | ||
do | ||
if ! test -f "ref/$f"; then | ||
echo "" | ||
echo "$f doesn't have a reference image to compare to" | ||
test_passed=false | ||
fi | ||
done | ||
|
||
mkdir -p diffs | ||
|
||
# For each image in the ref directory, check that there is a corresponding image in the current directory and then compare them | ||
for f in ref/*.png | ||
do | ||
echo "" | ||
base_name=$(basename ${f}) | ||
|
||
if test -f "$base_name"; then | ||
filename_no_ext="${base_name%.*}" | ||
echo "Comparing $base_name and $f" | ||
odiff --antialiasing --threshold=0.1 --diff-mask $base_name $f diffs/${filename_no_ext}-diff.png | ||
if [ $? -ne 0 ]; then | ||
test_passed=false | ||
fi | ||
else | ||
echo "Couldn't find image to compare against $f" | ||
test_passed=false | ||
fi | ||
done | ||
|
||
echo "" | ||
echo "===========================" | ||
if [ "$test_passed" = true ] ; then | ||
echo "All comparisons passed" | ||
echo "===========================" | ||
exit 0 | ||
else | ||
echo "Some comparisons failed" | ||
echo "===========================" | ||
exit 0 # In future (if we can make the image comparison more robust) we should exit with a non-zero exit code (e.g. 1) | ||
fi |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.