Skip to content

Commit 6134625

Browse files
committed
Sort imports and cleanup pre-commit, CI workflow
1 parent 123c537 commit 6134625

29 files changed

+429
-222
lines changed

.pre-commit-config.yaml

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# See: https://pre-commit.com/hooks.html
22
# Must put flake8 in separate group so 'black' is executed first
3+
# WARNING: Make sure to keep flags in sync with ci/run-linter.sh
34
repos:
45
- repo: https://github.com/pre-commit/pre-commit-hooks
56
rev: v3.1.0
@@ -11,6 +12,7 @@ repos:
1112
- id: end-of-file-fixer
1213
- id: trailing-whitespace
1314

15+
# apply after format() kwargs broken up into setters
1416
# - repo: https://github.com/ambv/black
1517
# rev: 19.10
1618
# hooks:
@@ -21,16 +23,17 @@ repos:
2123
rev: v4.3.21
2224
hooks:
2325
- id: isort
24-
args: ['--line-width', '88']
26+
args: ['--line-width=88', '--multi-line=3', '--force-grid-wrap=0', '--trailing-comma']
2527

2628
- repo: https://github.com/PyCQA/flake8
2729
rev: 3.8.3
2830
hooks:
2931
- id: flake8
3032
args: ['--max-line-length=88', '--ignore=W503,E402,E741']
3133

32-
- repo: https://github.com/PyCQA/doc8
33-
rev: 0.8.1
34-
hooks:
35-
- id: doc8
36-
args: ['--max-line-length', '88', '--allow-long-titles']
34+
# apply once this handles long tables better
35+
# - repo: https://github.com/PyCQA/doc8
36+
# rev: 0.8.1
37+
# hooks:
38+
# - id: doc8
39+
# args: ['--max-line-length', '88', '--allow-long-titles']

INSTALL.rst

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
Installation
22
============
33

4-
ProPlot is published on `PyPi <https://pypi.org/project/proplot/>`__ and `conda-forge <https://conda-forge.org>`__. It can be installed with ``pip`` or ``conda`` as follows:
4+
ProPlot is published on `PyPi <https://pypi.org/project/proplot/>`__
5+
and `conda-forge <https://conda-forge.org>`__. It can be installed
6+
with ``pip`` or ``conda`` as follows:
57

68
.. code-block:: bash
79
@@ -16,6 +18,13 @@ Likewise, an existing installation of ProPlot can be upgraded to the latest vers
1618
conda upgrade proplot
1719
1820
19-
To install a development version of ProPlot, you can use ``pip install git+https://github.com/lukelbd/proplot.git`` or clone the repository and run ``pip install -e .`` inside the ``proplot`` folder.
21+
To install a development version of ProPlot, you can use
22+
``pip install git+https://github.com/lukelbd/proplot.git``
23+
or clone the repository and run ``pip install -e .`` inside
24+
the ``proplot`` folder.
2025

21-
ProPlot's only hard dependency is `matplotlib <https://matplotlib.org/>`__. The *soft* dependencies are `cartopy <https://scitools.org.uk/cartopy/docs/latest/>`__, `basemap <https://matplotlib.org/basemap/index.html>`__, `xarray <http://xarray.pydata.org>`__, and `pandas <https://pandas.pydata.org>`__. See the documentation for details.
26+
ProPlot's only hard dependency is `matplotlib <https://matplotlib.org/>`__.
27+
The *soft* dependencies are `cartopy <https://scitools.org.uk/cartopy/docs/latest/>`__,
28+
`basemap <https://matplotlib.org/basemap/index.html>`__,
29+
`xarray <http://xarray.pydata.org>`__, and `pandas <https://pandas.pydata.org>`__.
30+
See the documentation for details.

README.rst

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ ProPlot is published on `PyPi <https://pypi.org/project/proplot/>`__ and
1818
pip install proplot
1919
conda install -c conda-forge proplot
2020
21-
Likewise, an existing installation of ProPlot can be upgraded to the latest version with:
21+
Likewise, an existing installation of ProPlot can be upgraded
22+
to the latest version with:
2223

2324
.. code-block:: bash
2425
2526
pip install --upgrade proplot
2627
conda upgrade proplot
2728
28-
To install a development version of ProPlot, you can use ``pip install git+https://github.com/lukelbd/proplot.git`` or clone the repository and run ``pip install -e .`` inside the ``proplot`` folder.
29+
To install a development version of ProPlot, you can use
30+
``pip install git+https://github.com/lukelbd/proplot.git``
31+
or clone the repository and run ``pip install -e .``
32+
inside the ``proplot`` folder.
2933

3034
Documentation
3135
=============

ci/run-linter.sh

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
#!/bin/bash
2+
# Run the travis CI tests
3+
# WARNING: Make sure to keep flags in sync with .pre-commit.config.yaml
24
set -e
35
set -eo pipefail
46

57
echo 'Code Styling with (flake8, isort)'
68

7-
source activate proplot-dev
8-
99
echo '[flake8]'
10-
flake8 proplot docs --max-line-length=88 --ignore=W503,E402,E741
10+
flake8 proplot docs --exclude .ipynb_checkpoints --max-line-length=88 --ignore=W503,E402,E741
1111

12-
# TODO: Add this
12+
# Apply after format() kwargs broken up into setters
1313
# echo '[black]'
1414
# black --check -S proplot
1515

1616
echo '[isort]'
17-
isort --recursive --check-only --line-width=88 proplot
17+
isort --recursive --check-only --line-width=88 --multi-line=3 --force-grid-wrap=0 --trailing-comma proplot
1818

19-
echo '[doc8]'
20-
doc8 *.rst docs --max-line-length=88
19+
# Apply once this handles long tables better
20+
# echo '[doc8]'
21+
# doc8 *.rst docs/*.rst --max-line-length=88

docs/faq.rst

+89-33
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,107 @@ Frequently asked questions
55
What makes this matplotlib wrapper different?
66
=============================================
77

8-
There is already a great matplotlib wrapper called `seaborn <https://seaborn.pydata.org/>`__. Also, `pandas <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.html>`__ and `xarray <http://xarray.pydata.org/en/stable/plotting.html>`__ both offer convenient matplotlib plotting commands. How does ProPlot compare against these tools?
9-
10-
* ProPlot, seaborn, pandas, and xarray all offer tools for generating rigid, simple, nice-looking plots from data stored in `~pandas.DataFrame`\ s and `~xarray.DataArray`\ s (ProPlot tries to apply labels from these objects, just like pandas and xarray).
11-
* Unlike seaborn, pandas, and xarray, ProPlot *also* works for arbitrarily complex subplot grids, and ProPlot provides tools for heavily customizing plots.
12-
* ProPlot is integrated with *cartopy* and *basemap*. You will find plotting geophysical data in ProPlot to be much more concise than working with cartopy and basemap directly.
13-
* ProPlot *expands upon* the seaborn tools for working with color and global settings. For example, see `~proplot.constructor.Colormap`, `~proplot.colors.PerceptuallyUniformColormap`, and `~proplot.config.RcConfigurator`.
14-
* ProPlot *expands upon* matplotlib by fixing various quirks, developing a more sophisticated automatic layout algorithm, simplifying the process of drawing outer colorbars and legends, and much more.
15-
* ProPlot is *built right into the matplotlib API*, thanks to special subclasses of the `~matplotlib.figure.Figure` and `~matplotlib.axes.Axes` classes, while seaborn, pandas, and xarray are meant to be used separately from the matplotlib API.
16-
17-
In a nutshell, ProPlot is intended to *unify the convenience of seaborn, pandas, and xarray plotting with the power and customizability of the underlying matplotlib API*.
8+
There is already a great matplotlib wrapper called
9+
`seaborn <https://seaborn.pydata.org/>`__. Also, `pandas\
10+
<https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.html>`__
11+
and `xarray <http://xarray.pydata.org/en/stable/plotting.html>`__
12+
both offer convenient matplotlib plotting commands.
13+
How does ProPlot compare against these tools?
14+
15+
* ProPlot, seaborn, pandas, and xarray all offer tools for generating rigid, simple,
16+
nice-looking plots from data stored in `~pandas.DataFrame`\ s and
17+
`~xarray.DataArray`\ s (ProPlot tries to apply labels from these objects, just like
18+
pandas and xarray).
19+
* Unlike seaborn, pandas, and xarray, ProPlot *also* works for arbitrarily complex
20+
subplot grids, and ProPlot provides tools for heavily customizing plots.
21+
* ProPlot is integrated with *cartopy* and *basemap*. You will find plotting geophysical
22+
data in ProPlot to be much more concise than working with cartopy and basemap
23+
directly.
24+
* ProPlot *expands upon* the seaborn tools for working with color and global settings.
25+
For example, see `~proplot.constructor.Colormap`,
26+
`~proplot.colors.PerceptuallyUniformColormap`, and `~proplot.config.RcConfigurator`.
27+
* ProPlot *expands upon* matplotlib by fixing various quirks, developing a more
28+
sophisticated automatic layout algorithm, simplifying the process of drawing outer
29+
colorbars and legends, and much more.
30+
* ProPlot is *built right into the matplotlib API*, thanks to special subclasses of the
31+
`~matplotlib.figure.Figure` and `~matplotlib.axes.Axes` classes, while seaborn,
32+
pandas, and xarray are meant to be used separately from the matplotlib API.
33+
34+
In a nutshell, ProPlot is intended to *unify the convenience of seaborn, pandas, and
35+
xarray plotting with the power and customizability of the underlying matplotlib API*.
1836

1937
..
2038
So while ProPlot includes similar tools, the scope and goals are largely different.
21-
Indeed, parts of ProPlot were inspired by these projects -- in particular, ``setup.py`` and ``colortools.py`` are modeled after seaborn. However the goals and scope of ProPlot are largely different:
39+
Indeed, parts of ProPlot were inspired by these projects -- in particular,
40+
``setup.py`` and ``colortools.py`` are modeled after seaborn. However the goals and
41+
scope of ProPlot are largely different:
2242
2343
Why didn't you add to matplotlib directly?
2444
==========================================
2545

26-
Since ProPlot is built right into the matplotlib API, you might be wondering why we didn't contribute to the matplotlib project directly.
27-
28-
* Certain features directly conflict with matplotlib. For example, ProPlot's tight layout algorithm conflicts with matplotlib's `tight layout <https://matplotlib.org/tutorials/intermediate/tight_layout_guide.html>`__ by permitting *fluid figure dimensions*, and the new `~proplot.gridspec.GridSpec` class permits *variable spacing* between rows and columns and uses *physical units* rather than figure-relative and axes-relative units.
29-
* Certain features are arguably too redundant. For example, `~proplot.axes.Axes.format` is convenient, but the same tasks can be accomplished with existing axes and axis "setter" methods. Also, some of the functionality of `~proplot.ui.subplots` can be replicated with `axes_grid1 <https://matplotlib.org/mpl_toolkits/axes_grid1/index.html>`__. Following `TOOWTDI <https://wiki.python.org/moin/TOOWTDI>`__ philosophy, these features should probably not be integrated.
46+
Since ProPlot is built right into the matplotlib API, you might be wondering why we
47+
didn't contribute to the matplotlib project directly.
48+
49+
* Certain features directly conflict with matplotlib. For example, ProPlot's tight
50+
layout algorithm conflicts with matplotlib's `tight layout\
51+
<https://matplotlib.org/tutorials/intermediate/tight_layout_guide.html>`__ by
52+
permitting *fluid figure dimensions*, and the new `~proplot.gridspec.GridSpec` class
53+
permits *variable spacing* between rows and columns and uses *physical units* rather
54+
than figure-relative and axes-relative units.
55+
* Certain features are arguably too redundant. For example, `~proplot.axes.Axes.format`
56+
is convenient, but the same tasks can be accomplished with existing axes and axis
57+
"setter" methods. Also, some of the functionality of `~proplot.ui.subplots` can be
58+
replicated with `axes_grid1\
59+
<https://matplotlib.org/mpl_toolkits/axes_grid1/index.html>`__. Following `TOOWTDI
60+
<https://wiki.python.org/moin/TOOWTDI>`__ philosophy, these features should probably
61+
not be integrated.
3062

3163
..
32-
* ProPlot design choices are made with the academic scientist working with ipython notebooks in mind, while matplotlib has a much more diverse base of hundreds of thousands of users. Matplotlib developers have to focus on support and API consistency, while ProPlot can make more dramatic improvements.
64+
* ProPlot design choices are made with the academic scientist working with ipython
65+
notebooks in mind, while matplotlib has a much more diverse base of hundreds of
66+
thousands of users. Matplotlib developers have to focus on support and API
67+
consistency, while ProPlot can make more dramatic improvements.
3368
34-
Nevertheless, if any core matplotlib developers think that some of ProPlot's features should be added to matplotlib, please contact `Luke Davis <https://github.com/lukelbd>`__ and let him know!
69+
Nevertheless, if any core matplotlib developers think that some of ProPlot's features
70+
should be added to matplotlib, please contact
71+
`Luke Davis <https://github.com/lukelbd>`__ and let him know!
3572

3673
Why do my inline figures look different?
3774
========================================
3875

39-
These days, most publications prefer plots saved as `vector graphics <https://en.wikipedia.org/wiki/Vector_graphics>`__ [1]_ rather than `raster graphics <https://en.wikipedia.org/wiki/Raster_graphics>`__ [2]_. When you save vector graphics, the content sizes should be appropriate for embedding the plot in a document (for example, if an academic journal recommends 8-point font for plots, you should use 8-point font in your plotting code).
40-
41-
Most of the default matplotlib backends make low-quality, artifact-plagued jpegs. To keep them legible, matplotlib uses a fairly large default figure width of 6.5 inches (usually only suitable for multi-panel plots) and a slightly large default font size of 10 points (where most journals recommend 5-9 points). This means your figures have to be downscaled so the sizes used in your plotting code are *not* the sizes that appear in the document.
76+
These days, most publications prefer plots saved as
77+
`vector graphics <https://en.wikipedia.org/wiki/Vector_graphics>`__ [1]_
78+
rather than `raster graphics <https://en.wikipedia.org/wiki/Raster_graphics>`__ [2]_.
79+
When you save vector graphics, the content sizes should be appropriate for embedding the
80+
plot in a document (for example, if an academic journal recommends 8-point font for
81+
plots, you should use 8-point font in your plotting code).
82+
83+
Most of the default matplotlib backends make low-quality, artifact-plagued jpegs. To
84+
keep them legible, matplotlib uses a fairly large default figure width of 6.5 inches
85+
(usually only suitable for multi-panel plots) and a slightly large default font size of
86+
10 points (where most journals recommend 5-9 points). This means your figures have to be
87+
downscaled so the sizes used in your plotting code are *not* the sizes that appear in
88+
the document.
89+
90+
ProPlot helps you get your figure sizes *correct* for embedding them as vector graphics
91+
inside publications. It uses a slightly smaller default font size, calculates the
92+
default figure size from the number of subplot rows and columns, and adds the `journal`
93+
keyword argument to `~proplot.figure.Figure` which can be used to employ figure
94+
dimensions from a particular journal standard. To keep the inline figures legible,
95+
ProPlot also employs a *higher quality* default inline backend.
96+
97+
.. [1] `Vector graphics <https://en.wikipedia.org/wiki/Vector_graphics>`__ use physical
98+
units (e.g. inches, `points <https://en.wikipedia.org/wiki/Point_(typography)>`__),
99+
are infinitely scalable, and often have much smaller file sizes than bitmap graphics.
100+
You should consider using them even when your plots are not destined for publication.
101+
PDF, SVG, and EPS are the most common formats.
102+
103+
.. [2] `Raster graphics <https://en.wikipedia.org/wiki/Raster_graphics>`__ use pixels
104+
and are *not* infinitely scalable. They tend to be faster to display and easier
105+
to view, but they are discouraged by most academic publishers. PNG and JPG are the
106+
most common formats.
42107
43-
ProPlot helps you get your figure sizes *correct* for embedding
44-
them as vector graphics inside publications.
45-
It uses a slightly smaller default font size, calculates the default figure
46-
size from the number of subplot rows and columns, and
47-
adds the `journal` keyword argument to `~proplot.figure.Figure` which can
48-
be used to employ figure dimensions from a particular journal standard.
49-
To keep the inline figures legible, ProPlot also employs a *higher quality* default
50-
inline backend.
51-
52-
.. [1] `Vector graphics <https://en.wikipedia.org/wiki/Vector_graphics>`__ use physical units (e.g. inches, `points <https://en.wikipedia.org/wiki/Point_(typography)>`__), are infinitely scalable, and often have much smaller file sizes than bitmap graphics. You should consider using them even when your plots are not destined for publication. PDF, SVG, and EPS are the most common formats.
53-
.. [2] `Raster graphics <https://en.wikipedia.org/wiki/Raster_graphics>`__ use pixels and are *not* infinitely scalable. They tend to be faster to display and easier to view, but they are discouraged by most academic publishers. PNG and JPG are the most common formats.
54-
55-
.. users to enlarge their figure dimensions and font sizes so that content inside of the inline figure is visible -- but when saving the figures for publication, it generally has to be shrunk back down!
108+
..
109+
users to enlarge their figure dimensions and font sizes so that content inside of the
110+
inline figure is visible -- but when saving the figures for publication, it generally
111+
has to be shrunk back down!

0 commit comments

Comments
 (0)