Skip to content

Commit 43943a7

Browse files
authored
Merge pull request #30 from bradyrx/add_aaas_journals
Add AAAS journals to subplot command
2 parents 7a611b5 + 32c4cc8 commit 43943a7

File tree

4 files changed

+48
-17
lines changed

4 files changed

+48
-17
lines changed

CHANGELOG.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
=================
12
Changelog History
23
=================
34

45
ProPlot v1.0.0
5-
--------------
6+
==============
67
First official release. Coming soon! Future changes and releases will be documented.
8+
9+
Internals/Minor Fixes
10+
---------------------
11+
- Add AAAS journal specifications to ``journal`` keyword for ``proplot.subplots()``, fix bug breaking on certain journals, add testing. (:pr:`30`) `Riley X. Brady`_.
12+
13+
14+
.. _`Luke Davis`: https://github.com/lukelbd
15+
.. _`Riley X. Brady`: https://github.com/bradyrx

docs/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
# 'matplotlib.sphinxext.plot_directive', # see: https://matplotlib.org/sampledoc/extensions.html
6262
]
6363

64+
extlinks = {
65+
'issue': ('https://github.com/lukelbd/proplot/issues/%s', 'GH#'),
66+
'pr': ('https://github.com/lukelbd/proplot/pull/%s', 'GH#'),
67+
}
68+
6469
# Do not run doctest tests, these are just to show syntax and expected
6570
# output may be graphical
6671
doctest_test_doctest_blocks = ''

proplot/subplots.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@
6161
't':'top',
6262
}
6363

64+
# Dimensions of figures for common journals
65+
JOURNAL_SPECS = {
66+
'pnas1': '8.7cm', # if 1 number specified, this is a tuple
67+
'pnas2': '11.4cm',
68+
'pnas3': '17.8cm',
69+
'ams1': 3.2, # spec is in inches
70+
'ams2': 4.5,
71+
'ams3': 5.5,
72+
'ams4': 6.5,
73+
'agu1': ('95mm', '115mm'),
74+
'agu2': ('190mm', '115mm'),
75+
'agu3': ('95mm', '230mm'),
76+
'agu4': ('190mm', '230mm'),
77+
'aaas1': '5.5cm', # AAAS (e.g., Science) 1 column
78+
'aaas2': '12cm', # AAAS 2 column
79+
}
80+
81+
6482
#-----------------------------------------------------------------------------#
6583
# Miscellaneous stuff
6684
#-----------------------------------------------------------------------------#
@@ -1630,28 +1648,16 @@ def _iter_axes(self):
16301648
#-----------------------------------------------------------------------------#
16311649
def _journals(journal):
16321650
"""Journal sizes for figures."""
1633-
table = {
1634-
'pnas1': '8.7cm', # if 1 number specified, this is a tuple
1635-
'pnas2': '11.4cm',
1636-
'pnas3': '17.8cm',
1637-
'ams1': 3.2, # spec is in inches
1638-
'ams2': 4.5,
1639-
'ams3': 5.5,
1640-
'ams4': 6.5,
1641-
'agu1': ('95mm', '115mm'),
1642-
'agu2': ('190mm', '115mm'),
1643-
'agu3': ('95mm', '230mm'),
1644-
'agu4': ('190mm', '230mm'),
1645-
}
1646-
value = table.get(journal, None)
1651+
# Get dimensions for figure from common journals.
1652+
value = JOURNAL_SPECS.get(journal, None)
16471653
if value is None:
16481654
raise ValueError(f'Unknown journal figure size specifier {journal!r}. ' +
1649-
'Current options are: ' + ', '.join(table.keys()))
1655+
'Current options are: ' + ', '.join(JOURNAL_SPECS.keys()))
16501656
# Return width, and optionally also the height
16511657
width, height = None, None
16521658
try:
16531659
width, height = value
1654-
except TypeError:
1660+
except (TypeError, ValueError):
16551661
width = value
16561662
return width, height
16571663

proplot/tests/test_journals.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
import proplot as plot
4+
from proplot.subplots import JOURNAL_SPECS
5+
6+
7+
# Loop through all available journals.
8+
@pytest.mark.parametrize('journal', JOURNAL_SPECS.keys())
9+
def test_journal_subplots(journal):
10+
"""Tests that subplots can be generated with journal specifications."""
11+
f, axs = plot.subplots(journal=journal)

0 commit comments

Comments
 (0)