diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 40d4af9..129c933 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,21 +13,16 @@ jobs: environment: name: publish steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.13" - name: Install build dependencies - run: pip install build + run: pip install -U build wheel twine - name: Build distribution run: python -m build - name: Publish - uses: pypa/gh-action-pypi-publish@v1.10.3 + uses: pypa/gh-action-pypi-publish@release/v1 - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJson(github) }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c331d72..4b0e5e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.13" - name: Install Linters run: | pip install -U pip @@ -27,17 +27,16 @@ jobs: test: env: - USING_COVERAGE: "3.11" + USING_COVERAGE: "3.13" strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] + python-version: ["3.11", "3.12", "3.13", "3.14"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install project diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5b621be..5d7ecfb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,10 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks default_language_version: - python: python3.11 + python: python3.13 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-added-large-files exclude: ".*.c" @@ -15,16 +15,16 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v3.19.1 + rev: v3.21.0 hooks: - id: pyupgrade args: - --py3-plus - --keep-runtime-typing - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.9.9 + rev: v0.14.2 hooks: - - id: ruff + - id: ruff-check args: - --fix - id: ruff-format diff --git a/docs/.buildinfo b/docs/.buildinfo index c6a343a..db5720e 100644 --- a/docs/.buildinfo +++ b/docs/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file records the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 8968451ad59f687a6baaff3671fc24a2 +config: 53f16db34476140cea1af3fd6d7d0e5e tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/.buildinfo.bak b/docs/.buildinfo.bak new file mode 100644 index 0000000..56a1a50 --- /dev/null +++ b/docs/.buildinfo.bak @@ -0,0 +1,4 @@ +# Sphinx build info version 1 +# This file records the configuration used when building these files. When it is not found, a full rebuild will be done. +config: 31646580202d31852527f5ace6edce70 +tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/_downloads/06ccbbd0c041413edf92a486cf420073/api-1.pdf b/docs/_downloads/06ccbbd0c041413edf92a486cf420073/api-1.pdf index a83cd81..893cf83 100644 Binary files a/docs/_downloads/06ccbbd0c041413edf92a486cf420073/api-1.pdf and b/docs/_downloads/06ccbbd0c041413edf92a486cf420073/api-1.pdf differ diff --git a/docs/_downloads/352e9685df5f6ec52e91c88710a7efee/api-2.py b/docs/_downloads/352e9685df5f6ec52e91c88710a7efee/api-2.py index 3d9f74d..23cc054 100644 --- a/docs/_downloads/352e9685df5f6ec52e91c88710a7efee/api-2.py +++ b/docs/_downloads/352e9685df5f6ec52e91c88710a7efee/api-2.py @@ -1,4 +1,5 @@ import matplotlib.pyplot as plt + from mpl_template import insert_image file = "img/polar_bar_demo.png" diff --git a/docs/_downloads/4621112975d0141aecaa9b8c5af477cf/api-3.py b/docs/_downloads/4621112975d0141aecaa9b8c5af477cf/api-3.py index e17a32e..1f0fae5 100644 --- a/docs/_downloads/4621112975d0141aecaa9b8c5af477cf/api-3.py +++ b/docs/_downloads/4621112975d0141aecaa9b8c5af477cf/api-3.py @@ -1,4 +1,5 @@ import matplotlib.pyplot as plt + from mpl_template import insert_image file = "img/polar_bar_demo.png" diff --git a/docs/_downloads/598066b5ada01e638fb320fe9ee5190f/api-2.pdf b/docs/_downloads/598066b5ada01e638fb320fe9ee5190f/api-2.pdf index a600db7..040476a 100644 Binary files a/docs/_downloads/598066b5ada01e638fb320fe9ee5190f/api-2.pdf and b/docs/_downloads/598066b5ada01e638fb320fe9ee5190f/api-2.pdf differ diff --git a/docs/_downloads/5d437c4702c6aba18e9f4548465fd95e/api-3.png b/docs/_downloads/5d437c4702c6aba18e9f4548465fd95e/api-3.png index 21464c4..b9d8c39 100644 Binary files a/docs/_downloads/5d437c4702c6aba18e9f4548465fd95e/api-3.png and b/docs/_downloads/5d437c4702c6aba18e9f4548465fd95e/api-3.png differ diff --git a/docs/_downloads/72ed800c349f28eee3b9cd3d69aaa370/api-3.hires.png b/docs/_downloads/72ed800c349f28eee3b9cd3d69aaa370/api-3.hires.png index 96494c5..2f95be3 100644 Binary files a/docs/_downloads/72ed800c349f28eee3b9cd3d69aaa370/api-3.hires.png and b/docs/_downloads/72ed800c349f28eee3b9cd3d69aaa370/api-3.hires.png differ diff --git a/docs/_downloads/7e4ee7c2895cb69f0314e63171a92eb2/api-2.png b/docs/_downloads/7e4ee7c2895cb69f0314e63171a92eb2/api-2.png index 581a6b8..d918603 100644 Binary files a/docs/_downloads/7e4ee7c2895cb69f0314e63171a92eb2/api-2.png and b/docs/_downloads/7e4ee7c2895cb69f0314e63171a92eb2/api-2.png differ diff --git a/docs/_downloads/9e46079d8d79e0ff79c453eb5113be5b/api-1.hires.png b/docs/_downloads/9e46079d8d79e0ff79c453eb5113be5b/api-1.hires.png index 345a79d..c97e748 100644 Binary files a/docs/_downloads/9e46079d8d79e0ff79c453eb5113be5b/api-1.hires.png and b/docs/_downloads/9e46079d8d79e0ff79c453eb5113be5b/api-1.hires.png differ diff --git a/docs/_downloads/a5c9a93625fec5298e20c27aba4d9a35/api-1.png b/docs/_downloads/a5c9a93625fec5298e20c27aba4d9a35/api-1.png index eb2bcec..fa56bb4 100644 Binary files a/docs/_downloads/a5c9a93625fec5298e20c27aba4d9a35/api-1.png and b/docs/_downloads/a5c9a93625fec5298e20c27aba4d9a35/api-1.png differ diff --git a/docs/_downloads/a9ead4fa61e3de6bd4f6261463b30ced/api-3.pdf b/docs/_downloads/a9ead4fa61e3de6bd4f6261463b30ced/api-3.pdf index ec18cf7..c26722a 100644 Binary files a/docs/_downloads/a9ead4fa61e3de6bd4f6261463b30ced/api-3.pdf and b/docs/_downloads/a9ead4fa61e3de6bd4f6261463b30ced/api-3.pdf differ diff --git a/docs/_downloads/ad5f3c227b17e7d378dbd9aa1d8400d4/api-2.hires.png b/docs/_downloads/ad5f3c227b17e7d378dbd9aa1d8400d4/api-2.hires.png index 3a6d892..55996c0 100644 Binary files a/docs/_downloads/ad5f3c227b17e7d378dbd9aa1d8400d4/api-2.hires.png and b/docs/_downloads/ad5f3c227b17e7d378dbd9aa1d8400d4/api-2.hires.png differ diff --git a/docs/_images/api-1.png b/docs/_images/api-1.png index eb2bcec..fa56bb4 100644 Binary files a/docs/_images/api-1.png and b/docs/_images/api-1.png differ diff --git a/docs/_images/api-2.png b/docs/_images/api-2.png index 581a6b8..d918603 100644 Binary files a/docs/_images/api-2.png and b/docs/_images/api-2.png differ diff --git a/docs/_images/api-3.png b/docs/_images/api-3.png index 21464c4..b9d8c39 100644 Binary files a/docs/_images/api-3.png and b/docs/_images/api-3.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_11_0.png b/docs/_images/notebooks_tutorial_Template_Docs_11_0.png index 947ce2e..45c4636 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_11_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_11_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_12_0.png b/docs/_images/notebooks_tutorial_Template_Docs_12_0.png index f1a45e1..e1516ff 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_12_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_12_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_14_0.png b/docs/_images/notebooks_tutorial_Template_Docs_14_0.png index 88017f0..375b93d 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_14_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_14_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_16_0.png b/docs/_images/notebooks_tutorial_Template_Docs_16_0.png index 53343dd..76701f8 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_16_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_16_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_18_0.png b/docs/_images/notebooks_tutorial_Template_Docs_18_0.png index 1795aa6..5061aaf 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_18_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_18_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_20_0.png b/docs/_images/notebooks_tutorial_Template_Docs_20_0.png index 1afc2f1..9c53a62 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_20_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_20_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_20_1.png b/docs/_images/notebooks_tutorial_Template_Docs_20_1.png index c7e1327..be7c2d2 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_20_1.png and b/docs/_images/notebooks_tutorial_Template_Docs_20_1.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_22_0.png b/docs/_images/notebooks_tutorial_Template_Docs_22_0.png index 8d3a7c0..65dc216 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_22_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_22_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_26_0.png b/docs/_images/notebooks_tutorial_Template_Docs_26_0.png index 1a896e6..cf627eb 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_26_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_26_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_28_0.png b/docs/_images/notebooks_tutorial_Template_Docs_28_0.png index abeca68..8d5d7d7 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_28_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_28_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_30_0.png b/docs/_images/notebooks_tutorial_Template_Docs_30_0.png index 0cd79cc..9de7c07 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_30_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_30_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_31_0.png b/docs/_images/notebooks_tutorial_Template_Docs_31_0.png index 48e080c..7729093 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_31_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_31_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_32_0.png b/docs/_images/notebooks_tutorial_Template_Docs_32_0.png index d3d93e9..023154b 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_32_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_32_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_34_0.png b/docs/_images/notebooks_tutorial_Template_Docs_34_0.png index 777199d..299c29c 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_34_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_34_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_4_0.png b/docs/_images/notebooks_tutorial_Template_Docs_4_0.png index a67eb70..fa0c525 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_4_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_4_0.png differ diff --git a/docs/_images/notebooks_tutorial_Template_Docs_7_0.png b/docs/_images/notebooks_tutorial_Template_Docs_7_0.png index ed9c5ba..e19eb22 100644 Binary files a/docs/_images/notebooks_tutorial_Template_Docs_7_0.png and b/docs/_images/notebooks_tutorial_Template_Docs_7_0.png differ diff --git a/docs/_modules/index.html b/docs/_modules/index.html index 672c8b4..b3a0e7a 100644 --- a/docs/_modules/index.html +++ b/docs/_modules/index.html @@ -5,15 +5,15 @@ - Overview: module code — mpl-template 0.6.0 documentation - + Overview: module code — mpl-template<br /><span style="font-size:.7rem">v0.7.0</span> 0.7.0 documentation + - + - + @@ -31,7 +31,7 @@ - mpl-template + mpl-template
v0.7.0
@@ -56,7 +56,7 @@
diff --git a/docs/_modules/mpl_template/template.html b/docs/_modules/mpl_template/template.html index 13812e8..618528f 100644 --- a/docs/_modules/mpl_template/template.html +++ b/docs/_modules/mpl_template/template.html @@ -5,15 +5,15 @@ - mpl_template.template — mpl-template 0.6.0 documentation - + mpl_template.template — mpl-template<br /><span style="font-size:.7rem">v0.7.0</span> 0.7.0 documentation + - + - + @@ -31,7 +31,7 @@ - mpl-template + mpl-template
v0.7.0
@@ -56,7 +56,7 @@
@@ -75,40 +75,40 @@

Source code for mpl_template.template

-import copy
-import io
-from pathlib import Path
-from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
+import copy
+import io
+from pathlib import Path
+from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
 
-import matplotlib.pyplot as plt
-from matplotlib import axes, figure, gridspec
+import matplotlib.pyplot as plt
+from matplotlib import axes, figure, gridspec
 
 __all__ = ["insert_image", "Template"]
 
 
 try:
-    import requests
+    import requests
 except ImportError:  # pragma: no cover
     if TYPE_CHECKING:
-        import requests
+        import requests
     else:
         requests = None
 
 
 try:
-    from PIL import Image
-    from PIL.ExifTags import TAGS
-    from PIL.Image import Resampling, Transpose  # type:ignore
+    from PIL import Image
+    from PIL.ExifTags import TAGS
+    from PIL.Image import Resampling, Transpose  # type:ignore
 except ImportError:  # pragma: no cover
     if TYPE_CHECKING:
-        from PIL import Image
-        from PIL.ExifTags import TAGS
-        from PIL.Image import Resampling, Transpose  # type:ignore
+        from PIL import Image
+        from PIL.ExifTags import TAGS
+        from PIL.Image import Resampling, Transpose  # type:ignore
     else:
         TAGS, Image = None, None
 
 
-def _calc_extents(size: int, scale: float) -> Tuple[float, float]:
+def _calc_extents(size: int, scale: float) -> Tuple[float, float]:
     """
     Calculates the view limits needed to see a
     centered image at the desired scale.
@@ -137,7 +137,7 @@ 

Source code for mpl_template.template

     return -lower, upper
 
 
-def _image_path_or_url(path: str) -> Union[str, io.BytesIO]:
+def _image_path_or_url(path: str) -> Union[str, io.BytesIO]:
     """
     Prepares image path or url for loading into format ready for
     loading by PIL.Image.open()
@@ -173,64 +173,55 @@ 

Source code for mpl_template.template

         return str(Path(path).resolve())
 
 
-def _apply_exif_rotation(im):
+def _apply_exif_rotation(im: Image.Image):
     """Apply exif rotation tag to a PIL image object
 
     Parameters
     ----------
-    im : PIL.Image
+    im : PIL.Image.Image
         image object that may contain rotation data
 
     Returns
     -------
-    PIL.Image
+    PIL.Image.Image
     """
-    if TAGS is None or Image is None:  # pragma: no cover
-        raise ImportError("The `pillow` library is required to manipulate images.")
-    i = im.copy()
-
-    try:
-        exif = {TAGS.get(tag): value for tag, value in im._getexif().items()}
-
-        # this section adapted from the following SO post:
-        # https://stackoverflow.com/a/1608846/7486933
-
-        orientation = exif.get("Orientation")
-        if orientation == 1:
-            # Nothing
-            i = im.copy()
-        elif orientation == 2:
-            # Vertical Mirror
-            i = im.transpose(Transpose.FLIP_LEFT_RIGHT)
-        elif orientation == 3:
-            # Rotation 180°
-            i = im.transpose(Transpose.ROTATE_180)
-        elif orientation == 4:
-            # Horizontal Mirror
-            i = im.transpose(Transpose.FLIP_TOP_BOTTOM)
-        elif orientation == 5:
-            # Horizontal Mirror + Rotation 90° CCW
-            i = im.transpose(Transpose.FLIP_TOP_BOTTOM).transpose(Transpose.ROTATE_90)
-        elif orientation == 6:
-            # Rotation 270°
-            i = im.transpose(Transpose.ROTATE_270)
-        elif orientation == 7:
-            # Horizontal Mirror + Rotation 270°
-            i = im.transpose(Transpose.FLIP_TOP_BOTTOM).transpose(Transpose.ROTATE_270)
-        elif orientation == 8:
-            # Rotation 90°
-            i = im.transpose(Transpose.ROTATE_90)
-        else:  # pragma: no cover
-            raise Exception("Invalid EXIF Orientation Value")
-        return i
-
-    except (AttributeError, KeyError, IndexError):
+
+    exif = {TAGS.get(tag): value for tag, value in im.getexif().items()}
+
+    # this section adapted from the following SO post:
+    # https://stackoverflow.com/a/1608846/7486933
+
+    orientation = exif.get("Orientation")
+    if orientation in [None, 1]:
         return im
+    if orientation == 2:
+        # Vertical Mirror
+        return im.transpose(Transpose.FLIP_LEFT_RIGHT)
+    if orientation == 3:
+        # Rotation 180°
+        return im.transpose(Transpose.ROTATE_180)
+    if orientation == 4:
+        # Horizontal Mirror
+        return im.transpose(Transpose.FLIP_TOP_BOTTOM)
+    if orientation == 5:
+        # Horizontal Mirror + Rotation 90° CCW
+        return im.transpose(Transpose.FLIP_TOP_BOTTOM).transpose(Transpose.ROTATE_90)
+    if orientation == 6:
+        # Rotation 270°
+        return im.transpose(Transpose.ROTATE_270)
+    if orientation == 7:
+        # Horizontal Mirror + Rotation 270°
+        return im.transpose(Transpose.FLIP_TOP_BOTTOM).transpose(Transpose.ROTATE_270)
+    if orientation == 8:
+        # Rotation 90°
+        return im.transpose(Transpose.ROTATE_90)
+
+    raise Exception("Invalid EXIF Orientation Value")  # pragma: no cover
 
 
 
[docs] -def insert_image( +def insert_image( ax: axes.Axes, image_path: str, scale: float = 1.0, @@ -312,9 +303,12 @@

Source code for mpl_template.template

 
     kwargs = {"xticks": [], "yticks": [], "zorder": 1} | kwargs
 
-    imgaxes = ax.figure.add_axes(ax.get_position(), **kwargs)
+    imgaxes = ax.figure.add_axes(
+        ax.get_position(),  # type: ignore
+        **kwargs,
+    )
     bbox = ax.get_window_extent().transformed(
-        ax.get_figure().dpi_scale_trans.inverted()  # type: ignore
+        ax.get_figure().dpi_scale_trans.inverted(),  # type: ignore
     )
     width, height = bbox.width, bbox.height
     width *= dpi
@@ -372,7 +366,7 @@ 

Source code for mpl_template.template

 
 
 
-def _get_default_tb_spans(
+def _get_default_tb_spans(
     rows: Tuple[int, ...], cols: Tuple[int, ...]
 ) -> List[Dict[str, Any]]:
     spans = [
@@ -385,7 +379,7 @@ 

Source code for mpl_template.template

     return spans
 
 
-def _validate_margins(
+def _validate_margins(
     margins: Optional[Tuple[int, int, int, int]] = None, base=10.0
 ) -> Tuple[int, int, int, int]:
     if margins is None:
@@ -398,7 +392,7 @@ 

Source code for mpl_template.template

 
 
[docs] -class Template: +class Template: """ Class to construct a report figure template using matplotlib which includes a figure border, script path, and title block. @@ -493,7 +487,7 @@

Source code for mpl_template.template

 
     """
 
-    def __init__(
+    def __init__(
         self,
         margins: Optional[Tuple[int, int, int, int]] = None,
         titleblock_content=None,
@@ -545,34 +539,34 @@ 

Source code for mpl_template.template

         self._titleblock_axes = []
 
     @property
-    def base(self):
+    def base(self):
         return self._base
 
     @property
-    def titleblock_axes(self):
+    def titleblock_axes(self):
         return self._titleblock_axes
 
     @property
-    def margins(self):
+    def margins(self):
         return self._margins
 
     @margins.setter
-    def margins(self, value):  # pragma: no cover
+    def margins(self, value):  # pragma: no cover
         self._margins = _validate_margins(value)
         self.left, self.right, self.top, self.bottom = self._margins
 
     @property
-    def titleblock_content(self):
+    def titleblock_content(self):
         if self._titleblock_content is None:
             self._titleblock_content = self.default_spans
         return self._titleblock_content
 
     @titleblock_content.setter  # pragma: no cover
-    def titleblock_content(self, value):
+    def titleblock_content(self, value):
         self._titleblock_content = value
 
     @property
-    def fig(self) -> figure.Figure:
+    def fig(self) -> figure.Figure:
         if self._fig is None:
             self._fig = plt.figure(**self._fig_options)
             if self.is_draft:  # pragma: no branch
@@ -580,11 +574,11 @@ 

Source code for mpl_template.template

         return self._fig
 
     @fig.setter
-    def fig(self, value):  # pragma: no cover
+    def fig(self, value):  # pragma: no cover
         self._fig = value
 
     @property
-    def gsfig(self):
+    def gsfig(self):
         if self._gsfig is None:  # pragma: no branch
             row = int(self.fig.get_figheight() * self.base)
             col = int(self.fig.get_figwidth() * self.base)
@@ -594,31 +588,31 @@ 

Source code for mpl_template.template

         return self._gsfig
 
     @gsfig.setter
-    def gsfig(self, value):  # pragma: no cover
+    def gsfig(self, value):  # pragma: no cover
         self._gsfig = value
 
     @property
-    def watermark(self):
+    def watermark(self):
         if self._watermark is None:
             self._watermark = self.add_watermark()
         return self._watermark
 
     @watermark.setter
-    def watermark(self, value):
+    def watermark(self, value):
         self._watermark = value
 
     @property
-    def path_text(self):
+    def path_text(self):
         if self._path_text is None:
             self._path_text = str(Path.cwd() / self.script_name)
         return self._path_text
 
     @path_text.setter
-    def path_text(self, value):
+    def path_text(self, value):
         self._path_text = value
 
     @property
-    def gstitleblock(self):
+    def gstitleblock(self):
         if self._gstitleblock is None:
             self._gstitleblock = self.gsfig[
                 -(self.bottom + self.t_h) or None : -self.bottom or None,
@@ -627,12 +621,12 @@ 

Source code for mpl_template.template

         return self._gstitleblock
 
     @gstitleblock.setter
-    def gstitleblock(self, value):
+    def gstitleblock(self, value):
         self._gstitleblock = value
         self._gstitleblock_subspec = None
 
     @property
-    def gstitleblock_subspec(self):
+    def gstitleblock_subspec(self):
         if self._gstitleblock_subspec is None:
             self._gstitleblock_subspec = gridspec.GridSpecFromSubplotSpec(
                 self.t_h,
@@ -644,24 +638,24 @@ 

Source code for mpl_template.template

         return self._gstitleblock_subspec
 
     @gstitleblock_subspec.setter
-    def gstitleblock_subspec(self, value):  # pragma: no cover
+    def gstitleblock_subspec(self, value):  # pragma: no cover
         self._gstitleblock_subspec = value
 
-    def add_frame(self):
+    def add_frame(self):
         fheight = self.base * self.fig.get_figheight()
         fwidth = self.base * self.fig.get_figwidth()
         _left = self.left / fwidth
         _right = self.right / fwidth
         _bottom = self.bottom / fheight
         _top = self.top / fheight
-        rect = [_left, _bottom, 1 - (_left + _right), 1 - (_bottom + _top)]
+        rect = (_left, _bottom, 1 - (_left + _right), 1 - (_bottom + _top))
 
         frame = self.fig.add_axes(
             rect, zorder=100, facecolor="none", xticks=[], yticks=[], label="frame"
         )
         return frame
 
-    def add_watermark(self, text=None):
+    def add_watermark(self, text=None):
         if text is None:  # pragma: no branch
             text = "DRAFT"
         x = (0.5 * self.base) / (self.base * self.fig.get_figwidth())
@@ -681,7 +675,7 @@ 

Source code for mpl_template.template

         self.watermark = watermark
         return self.watermark
 
-    def add_titleblock(self):
+    def add_titleblock(self):
         if len(self.titleblock_axes) > 0:
             return self.titleblock_axes
 
@@ -713,9 +707,9 @@ 

Source code for mpl_template.template

 
         return self.titleblock_axes
 
-    def add_page(self):  # pragma: no cover
+    def add_page(self):  # pragma: no cover
         ax = self.fig.add_axes(
-            [0, 0, 1, 1],
+            (0, 0, 1, 1),
             zorder=1000,
             facecolor="none",
             xticks=[],
@@ -724,7 +718,7 @@ 

Source code for mpl_template.template

         )
         return ax
 
-    def add_path_text(self):
+    def add_path_text(self):
         x = self.left / (self.base * self.fig.get_figwidth())
         y = abs(
             (self.bottom - 0.15 * self.base) / (self.base * self.fig.get_figheight())
@@ -741,9 +735,9 @@ 

Source code for mpl_template.template

 
         return textobj
 
-    def populate_titleblock(self):
+    def populate_titleblock(self):
         for i, (ax, dct) in enumerate(
-            zip(self.titleblock_axes, self.titleblock_content)
+            zip(self.titleblock_axes, self.titleblock_content, strict=True)
         ):
             assert ax.get_label() == dct.get("name", "b_{}".format(i)), (
                 "Axes are out of order."
@@ -776,7 +770,7 @@ 

Source code for mpl_template.template

                 img_ax.set_label("img_b_{}".format(i))
                 img_ax.axis("off")
 
-    def setup_figure(self) -> figure.Figure:
+    def setup_figure(self) -> figure.Figure:
         _ = self.add_frame()
         _ = self.add_titleblock()
         _ = self.add_path_text()
@@ -784,7 +778,7 @@ 

Source code for mpl_template.template

 
         return self.fig
 
-    def blank(self, with_labels=True) -> figure.Figure:
+    def blank(self, with_labels=True) -> figure.Figure:
         self.add_frame()
         axes = self.add_titleblock()
         if with_labels:
diff --git a/docs/_sources/notebooks/tutorial/Template_Docs.ipynb.txt b/docs/_sources/notebooks/tutorial/Template_Docs.ipynb.txt
index f343d1d..26e0440 100644
--- a/docs/_sources/notebooks/tutorial/Template_Docs.ipynb.txt
+++ b/docs/_sources/notebooks/tutorial/Template_Docs.ipynb.txt
@@ -17,8 +17,9 @@
    "source": [
     "import copy\n",
     "import os\n",
-    "import matplotlib.pyplot as plt\n",
+    "\n",
     "import matplotlib.gridspec as gs\n",
+    "import matplotlib.pyplot as plt\n",
     "import numpy as np\n",
     "\n",
     "from mpl_template import Template, insert_image\n",
diff --git a/docs/_static/basic.css b/docs/_static/basic.css
index 93a4776..9c0c9b8 100644
--- a/docs/_static/basic.css
+++ b/docs/_static/basic.css
@@ -741,14 +741,6 @@ abbr, acronym {
     cursor: help;
 }
 
-.translated {
-    background-color: rgba(207, 255, 207, 0.2)
-}
-
-.untranslated {
-    background-color: rgba(255, 207, 207, 0.2)
-}
-
 /* -- code displays --------------------------------------------------------- */
 
 pre {
diff --git a/docs/_static/documentation_options.js b/docs/_static/documentation_options.js
index 882be4b..ed79561 100644
--- a/docs/_static/documentation_options.js
+++ b/docs/_static/documentation_options.js
@@ -1,5 +1,5 @@
 const DOCUMENTATION_OPTIONS = {
-    VERSION: '0.6.0',
+    VERSION: '0.7.0',
     LANGUAGE: 'en',
     COLLAPSE_INDEX: false,
     BUILDER: 'html',
diff --git a/docs/_static/js/versions.js b/docs/_static/js/versions.js
index 26cf995..88c235b 100644
--- a/docs/_static/js/versions.js
+++ b/docs/_static/js/versions.js
@@ -1,6 +1,6 @@
 const themeFlyoutDisplay = "hidden";
-const themeVersionSelector = "True";
-const themeLanguageSelector = "True";
+const themeVersionSelector = true;
+const themeLanguageSelector = true;
 
 if (themeFlyoutDisplay === "attached") {
   function renderLanguages(config) {
@@ -8,10 +8,14 @@ if (themeFlyoutDisplay === "attached") {
       return "";
     }
 
+    // Insert the current language to the options on the selector
+    let languages = config.projects.translations.concat(config.projects.current);
+    languages = languages.sort((a, b) => a.language.name.localeCompare(b.language.name));
+
     const languagesHTML = `
       
Languages
- ${config.projects.translations + ${languages .map( (translation) => `
diff --git a/docs/_static/pygments.css b/docs/_static/pygments.css index 483d0fc..27836fa 100644 --- a/docs/_static/pygments.css +++ b/docs/_static/pygments.css @@ -6,9 +6,9 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: .highlight .hll { background-color: #ffffcc } .highlight { background: #f8f8f8; } .highlight .c { color: #3D7B7B; font-style: italic } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ +.highlight .err { border: 1px solid #F00 } /* Error */ .highlight .k { color: #008000; font-weight: bold } /* Keyword */ -.highlight .o { color: #666666 } /* Operator */ +.highlight .o { color: #666 } /* Operator */ .highlight .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */ .highlight .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */ .highlight .cp { color: #9C6500 } /* Comment.Preproc */ @@ -25,34 +25,34 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: .highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.highlight .gt { color: #0044DD } /* Generic.Traceback */ +.highlight .gt { color: #04D } /* Generic.Traceback */ .highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008000 } /* Keyword.Pseudo */ .highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #B00040 } /* Keyword.Type */ -.highlight .m { color: #666666 } /* Literal.Number */ +.highlight .m { color: #666 } /* Literal.Number */ .highlight .s { color: #BA2121 } /* Literal.String */ .highlight .na { color: #687822 } /* Name.Attribute */ .highlight .nb { color: #008000 } /* Name.Builtin */ -.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ -.highlight .no { color: #880000 } /* Name.Constant */ -.highlight .nd { color: #AA22FF } /* Name.Decorator */ +.highlight .nc { color: #00F; font-weight: bold } /* Name.Class */ +.highlight .no { color: #800 } /* Name.Constant */ +.highlight .nd { color: #A2F } /* Name.Decorator */ .highlight .ni { color: #717171; font-weight: bold } /* Name.Entity */ .highlight .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */ -.highlight .nf { color: #0000FF } /* Name.Function */ +.highlight .nf { color: #00F } /* Name.Function */ .highlight .nl { color: #767600 } /* Name.Label */ -.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ +.highlight .nn { color: #00F; font-weight: bold } /* Name.Namespace */ .highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #19177C } /* Name.Variable */ -.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mb { color: #666666 } /* Literal.Number.Bin */ -.highlight .mf { color: #666666 } /* Literal.Number.Float */ -.highlight .mh { color: #666666 } /* Literal.Number.Hex */ -.highlight .mi { color: #666666 } /* Literal.Number.Integer */ -.highlight .mo { color: #666666 } /* Literal.Number.Oct */ +.highlight .ow { color: #A2F; font-weight: bold } /* Operator.Word */ +.highlight .w { color: #BBB } /* Text.Whitespace */ +.highlight .mb { color: #666 } /* Literal.Number.Bin */ +.highlight .mf { color: #666 } /* Literal.Number.Float */ +.highlight .mh { color: #666 } /* Literal.Number.Hex */ +.highlight .mi { color: #666 } /* Literal.Number.Integer */ +.highlight .mo { color: #666 } /* Literal.Number.Oct */ .highlight .sa { color: #BA2121 } /* Literal.String.Affix */ .highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ .highlight .sc { color: #BA2121 } /* Literal.String.Char */ @@ -67,9 +67,9 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: .highlight .s1 { color: #BA2121 } /* Literal.String.Single */ .highlight .ss { color: #19177C } /* Literal.String.Symbol */ .highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ -.highlight .fm { color: #0000FF } /* Name.Function.Magic */ +.highlight .fm { color: #00F } /* Name.Function.Magic */ .highlight .vc { color: #19177C } /* Name.Variable.Class */ .highlight .vg { color: #19177C } /* Name.Variable.Global */ .highlight .vi { color: #19177C } /* Name.Variable.Instance */ .highlight .vm { color: #19177C } /* Name.Variable.Magic */ -.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ +.highlight .il { color: #666 } /* Literal.Number.Integer.Long */ diff --git a/docs/_static/searchtools.js b/docs/_static/searchtools.js index 2c774d1..91f4be5 100644 --- a/docs/_static/searchtools.js +++ b/docs/_static/searchtools.js @@ -513,9 +513,11 @@ const Search = { // perform the search on the required terms searchTerms.forEach((word) => { const files = []; + // find documents, if any, containing the query word in their text/title term indices + // use Object.hasOwnProperty to avoid mismatching against prototype properties const arr = [ - { files: terms[word], score: Scorer.term }, - { files: titleTerms[word], score: Scorer.title }, + { files: terms.hasOwnProperty(word) ? terms[word] : undefined, score: Scorer.term }, + { files: titleTerms.hasOwnProperty(word) ? titleTerms[word] : undefined, score: Scorer.title }, ]; // add support for partial matches if (word.length > 2) { @@ -547,8 +549,9 @@ const Search = { // set score for the word in each file recordFiles.forEach((file) => { - if (!scoreMap.has(file)) scoreMap.set(file, {}); - scoreMap.get(file)[word] = record.score; + if (!scoreMap.has(file)) scoreMap.set(file, new Map()); + const fileScores = scoreMap.get(file); + fileScores.set(word, record.score); }); }); @@ -587,7 +590,7 @@ const Search = { break; // select one (max) score for the file. - const score = Math.max(...wordList.map((w) => scoreMap.get(file)[w])); + const score = Math.max(...wordList.map((w) => scoreMap.get(file).get(w))); // add result to the result list results.push([ docNames[file], diff --git a/docs/api.html b/docs/api.html index 1a85736..4951507 100644 --- a/docs/api.html +++ b/docs/api.html @@ -6,15 +6,15 @@ - Template API Reference — mpl-template 0.6.0 documentation - + Template API Reference — mpl-template<br /><span style="font-size:.7rem">v0.7.0</span> 0.7.0 documentation + - + - + @@ -33,7 +33,7 @@ - mpl-template + mpl-template
v0.7.0
@@ -64,7 +64,7 @@
@@ -86,16 +86,16 @@

Template API Reference

-class mpl_template.template.Template(margins: Tuple[int, int, int, int] | None = None, titleblock_content=None, titleblock_cols=None, titleblock_rows=None, scriptname=None, draft=True, base=None, dpi: float = 300, **figkwargs)[source]
+class mpl_template.template.Template(margins: Tuple[int, int, int, int] | None = None, titleblock_content=None, titleblock_cols=None, titleblock_rows=None, scriptname=None, draft=True, base=None, dpi: float = 300, **figkwargs)[source]

Class to construct a report figure template using matplotlib which includes a figure border, script path, and title block.

Parameters:
    -
  • scriptname (str) – Path to the script or notebook that is creating the figure.

  • -
  • margins (tuple of int, optional (default = (4, 4, 4, 4)) – A length-4 tuple specifying the left, right, top, and bottom +

  • scriptname (str) – Path to the script or notebook that is creating the figure.

  • +
  • margins (tuple of int, optional (default = (4, 4, 4, 4)) – A length-4 tuple specifying the left, right, top, and bottom margins of on the page, respectively

  • -
  • titleblock_content (list of dicts, optional) –

    Title block elements where each element is itself a +

  • titleblock_content (list of dicts, optional) –

    Title block elements where each element is itself a dictionary with a span keys that determines which rows and columns the each element will occupy in the titleblock. E.g.

    @@ -148,13 +148,13 @@

-
  • titleblock_cols (tuple of int, optional (default=(16, 16, 8))) – The specification (in tenths of an inch) of the rulers for +

  • titleblock_cols (tuple of int, optional (default=(16, 16, 8))) – The specification (in tenths of an inch) of the rulers for each column in the title block.

  • -
  • titleblock_rows (tuple of int, optional (default=(8, 5, 3))) – The specification (in tenths of an inch) of the rulers for +

  • titleblock_rows (tuple of int, optional (default=(8, 5, 3))) – The specification (in tenths of an inch) of the rulers for each rows in the title block.

  • -
  • draft (bool, optional (default=True)) – Toggles the inclusion of a draft watermark.

  • -
  • base (int, optional (default=10)) – Number of gridspec rows and columns per inch.

  • -
  • dpi (int, optional (default=300)) – Resolution of the final figure in dots per inch.

  • +
  • draft (bool, optional (default=True)) – Toggles the inclusion of a draft watermark.

  • +
  • base (int, optional (default=10)) – Number of gridspec rows and columns per inch.

  • +
  • dpi (int, optional (default=300)) – Resolution of the final figure in dots per inch.

  • **figkwargs – Additional keyword arguments passed to plt.figure

  • @@ -162,7 +162,7 @@

    Examples

    To produce an empty figure containing a border object, and 5 title block objects:

    -
    >>> from mpl_template import Template
    +
    >>> from mpl_template import Template
     >>> report_fig = Template(figsize=(8.5, 11), scriptname="path/to/script.py")
     >>> fig = report_fig.blank()
     
    @@ -178,21 +178,21 @@

    insert_image API Reference

    -mpl_template.template.insert_image(ax: Axes, image_path: str, scale: float = 1.0, dpi: float = 300.0, expand: bool = False, **kwargs) Axes[source]
    +mpl_template.template.insert_image(ax: Axes, image_path: str, scale: float = 1.0, dpi: float = 300.0, expand: bool = False, **kwargs) Axes[source]

    Centers an image within an axes object

    Parameters:
    • ax (matplotlib.Axes) – the axes into which the image should be inserted.

    • -
    • image_path (str) – Path to an existing image file.

    • -
    • scale (float, optional) – The relative scale of the desired output. +

    • image_path (str) – Path to an existing image file.

    • +
    • scale (float, optional) – The relative scale of the desired output. Values should be positive floats. E.g. scale = 2 will double the image’s size relative to the given matplotlib.Axes object. scale = 0.5 will scale the image to half of the given matplotlib.Axes object.

    • -
    • dpi (int, optional (default=300)) – The Dots (pixel) Per Inch of the image.

    • -
    • expand (bool, optional (default=False)) – If true, the image will expand to fill the axes +

    • dpi (int, optional (default=300)) – The Dots (pixel) Per Inch of the image.

    • +
    • expand (bool, optional (default=False)) – If true, the image will expand to fill the axes in which it is embedded. Use expand = True if the boundary of the enclosing axes is the desired crop boundary. Use expand = False if the image should be scaled in-place @@ -216,8 +216,8 @@

      insert_imageZoomed out 2x with scale=0.5. Note that the enclosing axes is square, and that the inserted axes is a landscape rectangle that matches the shape of the source file.

      -
      >>> import matplotlib.pyplot as plt
      ->>> from mpl_template import insert_image
      +
      >>> import matplotlib.pyplot as plt
      +>>> from mpl_template import insert_image
       >>> file = "img/polar_bar_demo.png"
       >>> fig, ax = plt.subplots(figsize=(3, 3))
       >>> img_ax = insert_image(ax, file, scale=0.5)
      @@ -229,8 +229,8 @@ 

      insert_image

      Zoomed in 2x with scale=2. Note that the use of the expand kwarg causes the zoomed image to fill the enclosing square axes object.

      -
      >>> import matplotlib.pyplot as plt
      ->>> from mpl_template import insert_image
      +
      >>> import matplotlib.pyplot as plt
      +>>> from mpl_template import insert_image
       >>> file = "img/polar_bar_demo.png"
       >>> fig, ax = plt.subplots(figsize=(3, 3))
       >>> img_ax = insert_image(ax, file, scale=2, expand=True)
      diff --git a/docs/genindex.html b/docs/genindex.html
      index 70b0607..429cc89 100644
      --- a/docs/genindex.html
      +++ b/docs/genindex.html
      @@ -5,15 +5,15 @@
       
         
         
      -  Index — mpl-template 0.6.0 documentation
      -      
      +  Index — mpl-template<br /><span style="font-size:.7rem">v0.7.0</span> 0.7.0 documentation
      +      
             
      -      
      +      
       
       
             
             
      -      
      +      
             
             
             
      @@ -31,7 +31,7 @@
       
       
                 
      -            mpl-template
      +            mpl-template
      v0.7.0
      @@ -56,7 +56,7 @@
      diff --git a/docs/index.html b/docs/index.html index 60c736f..82052b2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,20 +6,18 @@ - mpl-template: Report-ready figure templating with matplotlib — mpl-template 0.6.0 documentation - + mpl-template: Report-ready figure templating with matplotlib — mpl-template<br /><span style="font-size:.7rem">v0.7.0</span> 0.7.0 documentation + - + - + - - @@ -35,7 +33,7 @@ - mpl-template + mpl-template
      v0.7.0
      @@ -60,7 +58,7 @@
      diff --git a/docs/notebooks/tutorial/Template_Docs.html b/docs/notebooks/tutorial/Template_Docs.html index af86532..8d120be 100644 --- a/docs/notebooks/tutorial/Template_Docs.html +++ b/docs/notebooks/tutorial/Template_Docs.html @@ -6,21 +6,19 @@ - Walkthrough — mpl-template 0.6.0 documentation - + Walkthrough — mpl-template<br /><span style="font-size:.7rem">v0.7.0</span> 0.7.0 documentation + - + - + - - @@ -37,7 +35,7 @@ - mpl-template + mpl-template
      v0.7.0
      @@ -82,7 +80,7 @@
      @@ -107,13 +105,14 @@

      Walkthrough
      [1]:
       

      -
      import copy
      -import os
      -import matplotlib.pyplot as plt
      -import matplotlib.gridspec as gs
      -import numpy as np
      +
      -
      import seaborn as sns
      +
      import seaborn as sns
       
       for i in range(2):
           with sns.axes_style("white"):
      diff --git a/docs/notebooks/tutorial/Template_Docs.ipynb b/docs/notebooks/tutorial/Template_Docs.ipynb
      index f343d1d..8b2f855 100644
      --- a/docs/notebooks/tutorial/Template_Docs.ipynb
      +++ b/docs/notebooks/tutorial/Template_Docs.ipynb
      @@ -17,8 +17,9 @@
          "source": [
           "import copy\n",
           "import os\n",
      -    "import matplotlib.pyplot as plt\n",
      +    "\n",
           "import matplotlib.gridspec as gs\n",
      +    "import matplotlib.pyplot as plt\n",
           "import numpy as np\n",
           "\n",
           "from mpl_template import Template, insert_image\n",
      @@ -1210,7 +1211,7 @@
          "name": "python",
          "nbconvert_exporter": "python",
          "pygments_lexer": "ipython3",
      -   "version": "3.11.10"
      +   "version": "3.13.9"
         }
        },
        "nbformat": 4,
      diff --git a/docs/objects.inv b/docs/objects.inv
      index 675926d..276fe89 100644
      Binary files a/docs/objects.inv and b/docs/objects.inv differ
      diff --git a/docs/overview.html b/docs/overview.html
      index 9cbafbc..e4df839 100644
      --- a/docs/overview.html
      +++ b/docs/overview.html
      @@ -6,15 +6,15 @@
         
       
         
      -  Purpose of mpl-template — mpl-template 0.6.0 documentation
      -      
      +  Purpose of mpl-template — mpl-template<br /><span style="font-size:.7rem">v0.7.0</span> 0.7.0 documentation
      +      
             
      -      
      +      
       
       
             
             
      -      
      +      
             
             
             
      @@ -32,7 +32,7 @@
       
       
                 
      -            mpl-template
      +            mpl-template
      v0.7.0
      @@ -57,7 +57,7 @@
      diff --git a/docs/search.html b/docs/search.html index 116c703..7247b1c 100644 --- a/docs/search.html +++ b/docs/search.html @@ -5,16 +5,16 @@ - Search — mpl-template 0.6.0 documentation - + Search — mpl-template<br /><span style="font-size:.7rem">v0.7.0</span> 0.7.0 documentation + - + - + @@ -34,7 +34,7 @@ - mpl-template + mpl-template
      v0.7.0
      @@ -59,7 +59,7 @@
      diff --git a/docs/searchindex.js b/docs/searchindex.js index f104100..2ea90ee 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"alltitles": {"API References": [[1, "api-references"]], "Advanced Features": [[2, "Advanced-Features"]], "Basics": [[2, "Basics"]], "Compatability with Seaborn": [[2, "Compatability-with-Seaborn"]], "Custom Titleblock Specifications": [[2, "Custom-Titleblock-Specifications"]], "FacetGrid": [[2, "FacetGrid"]], "Fully Custom Titleblock": [[2, "Fully-Custom-Titleblock"]], "Indices and tables": [[1, "indices-and-tables"]], "Inserting a Plot": [[2, "Inserting-a-Plot"]], "Inserting an Image": [[2, "Inserting-an-Image"]], "Just for fun\u2026": [[2, "Just-for-fun..."]], "Plots with Insets": [[2, "Plots-with-Insets"]], "Purpose of mpl-template": [[1, "purpose-of-mpl-template"], [3, null]], "Template API Reference": [[0, null]], "Titleblock": [[2, "Titleblock"]], "Tutorial": [[1, "tutorial"]], "Under The Hood": [[2, "Under-The-Hood"]], "User Defined Titleblock": [[2, "User-Defined-Titleblock"]], "Walkthrough": [[2, null]], "insert_image API Reference": [[0, "insert-image-api-reference"]], "mpl-template: Report-ready figure templating with matplotlib": [[1, null]]}, "docnames": ["api", "index", "notebooks/tutorial/Template_Docs", "overview"], "envversion": {"nbsphinx": 4, "sphinx": 64, "sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.intersphinx": 1, "sphinx.ext.todo": 2, "sphinx.ext.viewcode": 1}, "filenames": ["api.rst", "index.rst", "notebooks\\tutorial\\Template_Docs.ipynb", "overview.rst"], "indexentries": {"insert_image() (in module mpl_template.template)": [[0, "mpl_template.template.insert_image", false]], "template (class in mpl_template.template)": [[0, "mpl_template.template.Template", false]]}, "objects": {"mpl_template.template": [[0, 0, 1, "", "Template"], [0, 1, 1, "", "insert_image"]]}, "objnames": {"0": ["py", "class", "Python class"], "1": ["py", "function", "Python function"]}, "objtypes": {"0": "py:class", "1": "py:function"}, "terms": {"": [0, 1, 2, 3], "0": [0, 2], "01": 2, "02d": 2, "06": 2, "1": [0, 2], "10": [0, 2], "100": 2, "101": 2, "11": [0, 2], "110": [0, 2], "12": 2, "13": 2, "14": 2, "15": 2, "16": [0, 2], "17": 2, "18": 2, "19": 2, "19302d": 2, "2": [0, 2], "20": 2, "21": 2, "210001": 2, "2122": 2, "25": 2, "26": 2, "2x": 0, "3": [0, 2], "30": 2, "300": [0, 2], "32": [0, 2], "34": 2, "39": 2, "4": [0, 2], "40": 2, "46": 2, "48": 2, "5": [0, 2], "50": 2, "52": 2, "54": 2, "58": 2, "6": 2, "63": 2, "7": 2, "75": 2, "77": 2, "8": [0, 2], "80": 2, "85": 2, "9": 2, "95_confid": 2, "A": [0, 2], "At": [1, 3], "By": 2, "For": 2, "If": [0, 2], "It": [0, 2], "NO": 2, "The": [0, 1, 3], "There": 2, "These": 2, "To": 0, "_": 2, "abov": 2, "ad": 2, "add_ax": [0, 2], "add_fram": 2, "add_pag": 2, "add_path_text": 2, "add_subplot": 2, "add_titleblock": 2, "addit": [0, 2], "address": 2, "adjust": 2, "advanc": 1, "affect": 0, "aid": [1, 3], "alien_landscap": 2, "align": 2, "all": [1, 2, 3], "also": [1, 2, 3], "an": [0, 1], "analysi": [1, 3], "ani": [1, 3], "antialias": 2, "anywher": 2, "api": [2, 3], "appendix": [1, 3], "appli": [0, 2], "ar": [0, 1, 2, 3], "arang": 2, "argument": 0, "arial": 2, "around": 2, "aspect": [0, 2], "assign": 2, "assist": 2, "attend": 2, "attent": 2, "attribut": 2, "austinorr": 1, "ax": [0, 1, 2, 3], "ax2": 2, "axes_styl": 2, "axi": 2, "b_0": 2, "b_1": 2, "b_2": 2, "b_3": 2, "b_4": 2, "base": [0, 2], "baselin": 2, "basic": 1, "bbox_inch": 2, "becaus": [0, 2], "becom": [1, 3], "been": [0, 2], "befor": 2, "begin": 0, "being": 2, "below": 2, "blank": [0, 2], "blank_fig": 2, "blend": 2, "block": [0, 2], "bold": [0, 2], "bool": [0, 2], "border": [0, 2], "both": 2, "bottom": [0, 2], "boundari": 0, "box": 2, "brand": 2, "break": 2, "build": [1, 2, 3], "built": [1, 2, 3], "builtin": 2, "c": 2, "c0": 2, "c2": 2, "call": 2, "can": [1, 2, 3], "cannot": 2, "capabl": [1, 3], "case": 2, "caus": 0, "cell": 2, "center": [0, 2], "chang": 2, "class": [0, 1, 2, 3], "close": 2, "code": [0, 2], "col": 2, "col_wrap": 2, "color": 2, "column": [0, 2], "com": 1, "command": 2, "commonli": [1, 3], "compani": [1, 3], "compat": 1, "compatibli": 2, "complet": 2, "compliat": 2, "condens": 2, "config": 2, "construct": [0, 2], "constructor": 0, "consult": [1, 3], "contain": [0, 2], "content": 2, "control": 2, "copi": 2, "creat": [0, 1, 2, 3], "crop": [0, 2], "custom": 1, "customiz": 2, "d": [1, 3], "data": [1, 3], "date": 2, "dct": 2, "deepcopi": 2, "default": [0, 2], "default_span": 2, "defin": 1, "definit": 2, "desir": 0, "detail": 2, "determin": 0, "dict": [0, 2], "dictionari": [0, 1, 2, 3], "differ": 2, "dimens": 2, "directli": 2, "document": [1, 3], "dot": 0, "doubl": 0, "down": 2, "dpi": [0, 2], "draft": [0, 2], "e": [0, 2], "each": [0, 2], "easili": [1, 3], "effici": [1, 3], "element": [0, 2], "embed": [0, 1, 3], "empti": [0, 2], "enclos": [0, 2], "engin": [1, 3], "ensur": 2, "entir": [1, 3], "enumer": 2, "etc": [1, 2, 3], "even": 2, "exactli": 2, "exampl": [0, 2], "exist": [0, 2], "expand": [0, 2], "export": 2, "extrem": 2, "f": 2, "facecolor": [0, 2], "facet": 2, "facet_grid": 2, "facetgrid": 1, "fals": [0, 2], "featur": 1, "fig": [0, 2], "figkwarg": 0, "fignum": 2, "figsiz": [0, 2], "figur": [0, 2, 3], "file": [0, 2], "filepath": [1, 3], "fill": [0, 2], "final": [0, 1, 2, 3], "first": 2, "flexibl": [1, 2, 3], "float": [0, 2], "follow": [0, 2], "fontdict": 2, "fontnam": 2, "fontsiz": 2, "fontstyl": 2, "fontweight": 2, "format": 2, "frame": [0, 2], "frameon": 2, "from": [0, 2], "front": 2, "fulli": 1, "fully_custom": 2, "fun": 1, "function": [1, 2, 3], "g": [0, 2], "g_ax": 2, "gener": 2, "get": 2, "get_ax": 2, "get_dpi": 2, "get_label": 2, "getcwd": 2, "github": 1, "give": 0, "given": [0, 2], "goto": [1, 3], "grid": 2, "gridspec": [0, 1, 2, 3], "gridspecfromsubplotspec": 2, "gs_timeseri": 2, "gsfig": 2, "gstitleblock": 2, "guidelin": 2, "h": 2, "ha": 2, "half": 0, "have": [0, 2], "height": [0, 2], "helper": [1, 2, 3], "here": 2, "hero_ax": 2, "hero_img_ax": 2, "high": 2, "higher": 2, "highli": 2, "hire": 0, "hood": 1, "horizont": 2, "howev": [1, 2, 3], "hspace": 2, "http": 1, "hundredth": 2, "i": [0, 1, 2, 3], "ident": 2, "illustr": 2, "im_ax": 2, "imag": [0, 1, 3], "image_path": 0, "img": [0, 2], "img_ax": 0, "img_b_1": 2, "implicit": 2, "import": [0, 2], "inch": [0, 1, 2, 3], "includ": [0, 1, 3], "inclus": 0, "increment": 2, "index": [1, 2], "indic": 2, "industri": [1, 3], "inlin": 2, "inlinebackend": 2, "input": 2, "insert": [0, 1, 3], "insert_imag": [1, 2, 3], "inset": [1, 3], "inset_ax": 2, "instanc": 2, "int": [0, 2], "integ": [0, 2], "intend": 2, "ipynb": 2, "ital": 2, "its": 0, "itself": 0, "join": 2, "jpg": 2, "june": 2, "just": 1, "kei": [0, 2], "keyword": 0, "knowledg": 2, "kwarg": [0, 2], "label": 2, "landscap": 0, "largest": 2, "layout": 2, "left": [0, 2], "length": 0, "level": 2, "light": [0, 2], "lightgrei": 2, "like": 2, "limit": 2, "list": [0, 1, 2, 3], "load": 2, "load_dataset": 2, "local": 2, "locat": 2, "logic": 2, "logo": [0, 1, 2, 3], "logo_ax": 2, "logo_g": 2, "logo_img_ax": 2, "loop": 2, "made": 2, "mai": 2, "main": 2, "make": [1, 2, 3], "mani": [1, 3], "map": 2, "margin": [0, 1, 2, 3], "marker": 2, "markers": 2, "match": 0, "matplotlib": [0, 2, 3], "mean": 2, "meant": 2, "metadata": [1, 3], "method": 2, "might": 2, "modif": 2, "modul": [1, 2, 3], "move": 2, "mpl_templat": [0, 2], "multipl": 2, "must": [0, 2], "my": [1, 2, 3], "n": 2, "n2122": 2, "name": [0, 2], "ncustom": 2, "neatlin": [1, 3], "necessari": 2, "new_span": 2, "next": 0, "nice": [1, 3], "none": [0, 2], "nostromo": 2, "note": [0, 2], "notebook": 0, "notic": 2, "now": 2, "np": 2, "number": [0, 1, 2, 3], "numpi": 2, "nuscss": 2, "o": 2, "object": [0, 2], "occupi": [0, 2], "one": 2, "onli": [0, 2], "open": [1, 3], "option": [0, 2], "order": 2, "orient": 2, "origin": [0, 2], "other": [1, 2, 3], "our": [1, 3], "out": [0, 2], "outer": [0, 2], "output": [0, 2], "overlai": 2, "overrid": 2, "overwritten": 2, "own": 2, "packag": [1, 2, 3], "page": [0, 1, 2], "paper": [1, 3], "paradigm": [1, 3], "paramet": 0, "parent": 0, "pass": [0, 2], "path": [0, 2], "path_text": 2, "pattern": 2, "pdf": [0, 2], "per": 0, "perform": 2, "pixel": 0, "place": 0, "plot": [1, 3], "plt": [0, 2], "png": [0, 2], "polar_bar_demo": 0, "popul": 2, "populate_titleblock": 2, "posit": 0, "possibl": 2, "precis": 2, "present": 2, "print": 2, "print_figure_kwarg": 2, "produc": [0, 1, 2, 3], "proj": 2, "project": 2, "properli": 2, "properti": 2, "provid": 2, "public": [1, 3], "py": 0, "pyplot": [0, 2], "qualiti": [1, 3], "r": 2, "r0": 2, "random": 2, "rang": 2, "rapidli": [1, 3], "raster": [1, 3], "ratio": [0, 2], "recommend": 2, "rectangl": 0, "referenc": 2, "rel": 0, "report": 0, "report_fig": [0, 2], "requir": [0, 2], "resolut": [0, 2], "respect": 0, "return": 0, "reveal": 2, "review": 2, "right": [0, 2], "row": [0, 2], "ruler": 0, "save": 2, "savefig": 2, "scale": [0, 2], "scienc": [1, 3], "score": 2, "script": [0, 1, 2, 3], "scriptnam": [0, 2], "seaborn": 1, "search": 1, "select": 2, "sep": 2, "set": 2, "set_axis_off": 2, "set_color": 2, "set_edgecolor": 2, "set_facecolor": 2, "set_linewidth": 2, "set_ylim": 2, "setup_figur": 2, "sever": 2, "shape": [0, 2], "ship": 2, "should": [0, 2], "show": 2, "shown": 2, "simpl": 2, "sin": 2, "size": [0, 1, 2, 3], "sn": 2, "solut": 2, "sourc": [0, 1, 3], "span": [0, 2], "spec": 2, "special": 2, "specif": [0, 1, 3], "specifi": [0, 1, 2, 3], "spine": 2, "split": 2, "squar": [0, 2], "stack": 2, "store": 2, "str": 0, "stretch": 2, "string": 2, "structur": 2, "style": 2, "sub": 2, "subfigur": 2, "subject": 2, "subplot": [0, 2], "subtitl": [0, 2], "t_h": 2, "t_w": 2, "tall": [0, 2], "task": 2, "tbk": [0, 2], "tblk_axlist": 2, "tediou": [1, 3], "templat": 2, "template_doc": 2, "template_inset": 2, "temporari": 2, "tenth": [0, 1, 2, 3], "test": 2, "text": [0, 2], "than": 2, "them": 2, "thi": [0, 1, 2, 3], "thing": 2, "those": [1, 3], "titeleblock": 2, "titl": [0, 2], "titleblock": [0, 1, 3], "titleblock_": 2, "titleblock_col": [0, 2], "titleblock_cont": [0, 2], "titleblock_row": [0, 2], "toggl": 0, "top": [0, 2], "true": [0, 2], "tupl": [0, 2], "two": 2, "type": 0, "typic": 2, "ubiquit": [1, 3], "under": 1, "underli": 2, "uniform": 2, "unit": 2, "untest": 2, "up": 2, "updat": 2, "us": [0, 1, 2, 3], "uscss": 2, "user": [1, 3], "user_specifi": 2, "va": 2, "valu": [0, 2], "variabl": 2, "veri": [1, 3], "vertic": 2, "via": 2, "w": 2, "wai": 2, "walkthrough": 1, "watermark": 0, "we": [1, 2, 3], "web": 2, "weight": [0, 2], "were": 2, "weyland": 2, "when": 2, "where": [0, 2], "which": [0, 2], "white": [0, 2], "wide": [0, 2], "width": [0, 2], "within": 0, "word": [1, 3], "work": 2, "would": 2, "wspace": 2, "x": 2, "xtick": 2, "y": 2, "ylim": 2, "you": 2, "ytick": 2, "yutani": 2, "zero": 0, "zoom": [0, 2], "zorder": [0, 2]}, "titles": ["Template API Reference", "mpl-template: Report-ready figure templating with matplotlib", "Walkthrough", "Purpose of mpl-template"], "titleterms": {"The": 2, "advanc": 2, "an": 2, "api": [0, 1], "basic": 2, "compat": 2, "custom": 2, "defin": 2, "facetgrid": 2, "featur": 2, "figur": 1, "fulli": 2, "fun": 2, "hood": 2, "imag": 2, "indic": 1, "insert": 2, "insert_imag": 0, "inset": 2, "just": 2, "matplotlib": 1, "mpl": [1, 3], "plot": 2, "purpos": [1, 3], "readi": 1, "refer": [0, 1], "report": 1, "seaborn": 2, "specif": 2, "tabl": 1, "templat": [0, 1, 3], "titleblock": 2, "tutori": 1, "under": 2, "user": 2, "walkthrough": 2}}) +Search.setIndex({"alltitles":{"API References":[[1,"api-references"]],"Advanced Features":[[2,"Advanced-Features"]],"Basics":[[2,"Basics"]],"Compatability with Seaborn":[[2,"Compatability-with-Seaborn"]],"Custom Titleblock Specifications":[[2,"Custom-Titleblock-Specifications"]],"FacetGrid":[[2,"FacetGrid"]],"Fully Custom Titleblock":[[2,"Fully-Custom-Titleblock"]],"Indices and tables":[[1,"indices-and-tables"]],"Inserting a Plot":[[2,"Inserting-a-Plot"]],"Inserting an Image":[[2,"Inserting-an-Image"]],"Just for fun\u2026":[[2,"Just-for-fun..."]],"Plots with Insets":[[2,"Plots-with-Insets"]],"Purpose of mpl-template":[[1,"purpose-of-mpl-template"],[3,null]],"Template API Reference":[[0,null]],"Titleblock":[[2,"Titleblock"]],"Tutorial":[[1,"tutorial"]],"Under The Hood":[[2,"Under-The-Hood"]],"User Defined Titleblock":[[2,"User-Defined-Titleblock"]],"Walkthrough":[[2,null]],"insert_image API Reference":[[0,"insert-image-api-reference"]],"mpl-template: Report-ready figure templating with matplotlib":[[1,null]]},"docnames":["api","index","notebooks/tutorial/Template_Docs","overview"],"envversion":{"nbsphinx":4,"sphinx":65,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.intersphinx":1,"sphinx.ext.todo":2,"sphinx.ext.viewcode":1},"filenames":["api.rst","index.rst","notebooks\\tutorial\\Template_Docs.ipynb","overview.rst"],"indexentries":{"insert_image() (in module mpl_template.template)":[[0,"mpl_template.template.insert_image",false]],"template (class in mpl_template.template)":[[0,"mpl_template.template.Template",false]]},"objects":{"mpl_template.template":[[0,0,1,"","Template"],[0,1,1,"","insert_image"]]},"objnames":{"0":["py","class","Python class"],"1":["py","function","Python function"]},"objtypes":{"0":"py:class","1":"py:function"},"terms":{"":[0,1,2,3],"0":[0,2],"01":2,"02d":2,"06":2,"1":[0,2],"10":[0,2],"100":2,"101":2,"11":[0,2],"110":[0,2],"12":2,"13":2,"14":2,"15":2,"16":[0,2],"17":2,"18":2,"19":2,"19302d":2,"2":[0,2],"20":2,"21":2,"210001":2,"2122":2,"25":2,"26":2,"2x":0,"3":[0,2],"30":2,"300":[0,2],"32":[0,2],"34":2,"39":2,"4":[0,2],"40":2,"46":2,"48":2,"5":[0,2],"50":2,"52":2,"54":2,"58":2,"6":2,"63":2,"7":2,"75":2,"77":2,"8":[0,2],"80":2,"85":2,"9":2,"95_confid":2,"A":[0,2],"At":[1,3],"By":2,"For":2,"If":[0,2],"It":[0,2],"NO":2,"The":[0,1,3],"There":2,"These":2,"To":0,"_":2,"abov":2,"ad":2,"add_ax":[0,2],"add_fram":2,"add_pag":2,"add_path_text":2,"add_subplot":2,"add_titleblock":2,"addit":[0,2],"address":2,"adjust":2,"advanc":1,"affect":0,"aid":[1,3],"alien_landscap":2,"align":2,"all":[1,2,3],"also":[1,2,3],"an":[0,1],"analysi":[1,3],"ani":[1,3],"antialias":2,"anywher":2,"api":[2,3],"appendix":[1,3],"appli":[0,2],"ar":[0,1,2,3],"arang":2,"argument":0,"arial":2,"around":2,"aspect":[0,2],"assign":2,"assist":2,"attend":2,"attent":2,"attribut":2,"austinorr":1,"ax":[0,1,2,3],"ax2":2,"axes_styl":2,"axi":2,"b_0":2,"b_1":2,"b_2":2,"b_3":2,"b_4":2,"base":[0,2],"baselin":2,"basic":1,"bbox_inch":2,"becaus":[0,2],"becom":[1,3],"been":[0,2],"befor":2,"begin":0,"being":2,"below":2,"blank":[0,2],"blank_fig":2,"blend":2,"block":[0,2],"bold":[0,2],"bool":[0,2],"border":[0,2],"both":2,"bottom":[0,2],"boundari":0,"box":2,"brand":2,"break":2,"build":[1,2,3],"built":[1,2,3],"builtin":2,"c":2,"c0":2,"c2":2,"call":2,"can":[1,2,3],"cannot":2,"capabl":[1,3],"case":2,"caus":0,"cell":2,"center":[0,2],"chang":2,"class":[0,1,2,3],"close":2,"code":[0,2],"col":2,"col_wrap":2,"color":2,"column":[0,2],"com":1,"command":2,"commonli":[1,3],"compani":[1,3],"compat":1,"compatibli":2,"complet":2,"compliat":2,"condens":2,"config":2,"construct":[0,2],"constructor":0,"consult":[1,3],"contain":[0,2],"content":2,"control":2,"copi":2,"creat":[0,1,2,3],"crop":[0,2],"custom":1,"customiz":2,"d":[1,3],"data":[1,3],"date":2,"dct":2,"deepcopi":2,"default":[0,2],"default_span":2,"defin":1,"definit":2,"desir":0,"detail":2,"determin":0,"dict":[0,2],"dictionari":[0,1,2,3],"differ":2,"dimens":2,"directli":2,"document":[1,3],"dot":0,"doubl":0,"down":2,"dpi":[0,2],"draft":[0,2],"e":[0,2],"each":[0,2],"easili":[1,3],"effici":[1,3],"element":[0,2],"embed":[0,1,3],"empti":[0,2],"enclos":[0,2],"engin":[1,3],"ensur":2,"entir":[1,3],"enumer":2,"etc":[1,2,3],"even":2,"exactli":2,"exampl":[0,2],"exist":[0,2],"expand":[0,2],"export":2,"extrem":2,"f":2,"facecolor":[0,2],"facet":2,"facet_grid":2,"facetgrid":1,"fals":[0,2],"featur":1,"fig":[0,2],"figkwarg":0,"fignum":2,"figsiz":[0,2],"figur":[0,2,3],"file":[0,2],"filepath":[1,3],"fill":[0,2],"final":[0,1,2,3],"first":2,"flexibl":[1,2,3],"float":[0,2],"follow":[0,2],"fontdict":2,"fontnam":2,"fontsiz":2,"fontstyl":2,"fontweight":2,"format":2,"frame":[0,2],"frameon":2,"from":[0,2],"front":2,"fulli":1,"fully_custom":2,"fun":1,"function":[1,2,3],"g":[0,2],"g_ax":2,"gener":2,"get":2,"get_ax":2,"get_dpi":2,"get_label":2,"getcwd":2,"github":1,"give":0,"given":[0,2],"goto":[1,3],"grid":2,"gridspec":[0,1,2,3],"gridspecfromsubplotspec":2,"gs_timeseri":2,"gsfig":2,"gstitleblock":2,"guidelin":2,"h":2,"ha":2,"half":0,"have":[0,2],"height":[0,2],"helper":[1,2,3],"here":2,"hero_ax":2,"hero_img_ax":2,"high":2,"higher":2,"highli":2,"hire":0,"hood":1,"horizont":2,"howev":[1,2,3],"hspace":2,"http":1,"hundredth":2,"i":[0,1,2,3],"ident":2,"illustr":2,"im_ax":2,"imag":[0,1,3],"image_path":0,"img":[0,2],"img_ax":0,"img_b_1":2,"implicit":2,"import":[0,2],"inch":[0,1,2,3],"includ":[0,1,3],"inclus":0,"increment":2,"index":[1,2],"indic":2,"industri":[1,3],"inlin":2,"inlinebackend":2,"input":2,"insert":[0,1,3],"insert_imag":[1,2,3],"inset":[1,3],"inset_ax":2,"instanc":2,"int":[0,2],"integ":[0,2],"intend":2,"ipynb":2,"ital":2,"its":0,"itself":0,"join":2,"jpg":2,"june":2,"just":1,"kei":[0,2],"keyword":0,"knowledg":2,"kwarg":[0,2],"label":2,"landscap":0,"largest":2,"layout":2,"left":[0,2],"length":0,"level":2,"light":[0,2],"lightgrei":2,"like":2,"limit":2,"list":[0,1,2,3],"load":2,"load_dataset":2,"local":2,"locat":2,"logic":2,"logo":[0,1,2,3],"logo_ax":2,"logo_g":2,"logo_img_ax":2,"loop":2,"made":2,"mai":2,"main":2,"make":[1,2,3],"mani":[1,3],"map":2,"margin":[0,1,2,3],"marker":2,"markers":2,"match":0,"matplotlib":[0,2,3],"mean":2,"meant":2,"metadata":[1,3],"method":2,"might":2,"modif":2,"modul":[1,2,3],"move":2,"mpl_templat":[0,2],"multipl":2,"must":[0,2],"my":[1,2,3],"n":2,"n2122":2,"name":[0,2],"ncustom":2,"neatlin":[1,3],"necessari":2,"new_span":2,"next":0,"nice":[1,3],"none":[0,2],"nostromo":2,"note":[0,2],"notebook":0,"notic":2,"now":2,"np":2,"number":[0,1,2,3],"numpi":2,"nuscss":2,"o":2,"object":[0,2],"occupi":[0,2],"one":2,"onli":[0,2],"open":[1,3],"option":[0,2],"order":2,"orient":2,"origin":[0,2],"other":[1,2,3],"our":[1,3],"out":[0,2],"outer":[0,2],"output":[0,2],"overlai":2,"overrid":2,"overwritten":2,"own":2,"packag":[1,2,3],"page":[0,1,2],"paper":[1,3],"paradigm":[1,3],"paramet":0,"parent":0,"pass":[0,2],"path":[0,2],"path_text":2,"pattern":2,"pdf":[0,2],"per":0,"perform":2,"pixel":0,"place":0,"plot":[1,3],"plt":[0,2],"png":[0,2],"polar_bar_demo":0,"popul":2,"populate_titleblock":2,"posit":0,"possibl":2,"precis":2,"present":2,"print":2,"print_figure_kwarg":2,"produc":[0,1,2,3],"proj":2,"project":2,"properli":2,"properti":2,"provid":2,"public":[1,3],"py":0,"pyplot":[0,2],"qualiti":[1,3],"r":2,"r0":2,"random":2,"rang":2,"rapidli":[1,3],"raster":[1,3],"ratio":[0,2],"recommend":2,"rectangl":0,"referenc":2,"rel":0,"report":0,"report_fig":[0,2],"requir":[0,2],"resolut":[0,2],"respect":0,"return":0,"reveal":2,"review":2,"right":[0,2],"row":[0,2],"ruler":0,"save":2,"savefig":2,"scale":[0,2],"scienc":[1,3],"score":2,"script":[0,1,2,3],"scriptnam":[0,2],"seaborn":1,"search":1,"select":2,"sep":2,"set":2,"set_axis_off":2,"set_color":2,"set_edgecolor":2,"set_facecolor":2,"set_linewidth":2,"set_ylim":2,"setup_figur":2,"sever":2,"shape":[0,2],"ship":2,"should":[0,2],"show":2,"shown":2,"simpl":2,"sin":2,"size":[0,1,2,3],"sn":2,"solut":2,"sourc":[0,1,3],"span":[0,2],"spec":2,"special":2,"specif":[0,1,3],"specifi":[0,1,2,3],"spine":2,"split":2,"squar":[0,2],"stack":2,"store":2,"str":0,"stretch":2,"string":2,"structur":2,"style":2,"sub":2,"subfigur":2,"subject":2,"subplot":[0,2],"subtitl":[0,2],"t_h":2,"t_w":2,"tall":[0,2],"task":2,"tbk":[0,2],"tblk_axlist":2,"tediou":[1,3],"templat":2,"template_doc":2,"template_inset":2,"temporari":2,"tenth":[0,1,2,3],"test":2,"text":[0,2],"than":2,"them":2,"thi":[0,1,2,3],"thing":2,"those":[1,3],"titeleblock":2,"titl":[0,2],"titleblock":[0,1,3],"titleblock_":2,"titleblock_col":[0,2],"titleblock_cont":[0,2],"titleblock_row":[0,2],"toggl":0,"top":[0,2],"true":[0,2],"tupl":[0,2],"two":2,"type":0,"typic":2,"ubiquit":[1,3],"under":1,"underli":2,"uniform":2,"unit":2,"untest":2,"up":2,"updat":2,"us":[0,1,2,3],"uscss":2,"user":[1,3],"user_specifi":2,"va":2,"valu":[0,2],"variabl":2,"veri":[1,3],"vertic":2,"via":2,"w":2,"wai":2,"walkthrough":1,"watermark":0,"we":[1,2,3],"web":2,"weight":[0,2],"were":2,"weyland":2,"when":2,"where":[0,2],"which":[0,2],"white":[0,2],"wide":[0,2],"width":[0,2],"within":0,"word":[1,3],"work":2,"would":2,"wspace":2,"x":2,"xtick":2,"y":2,"ylim":2,"you":2,"ytick":2,"yutani":2,"zero":0,"zoom":[0,2],"zorder":[0,2]},"titles":["Template API Reference","mpl-template: Report-ready figure templating with matplotlib","Walkthrough","Purpose of mpl-template"],"titleterms":{"The":2,"advanc":2,"an":2,"api":[0,1],"basic":2,"compat":2,"custom":2,"defin":2,"facetgrid":2,"featur":2,"figur":1,"fulli":2,"fun":2,"hood":2,"imag":2,"indic":1,"insert":2,"insert_imag":0,"inset":2,"just":2,"matplotlib":1,"mpl":[1,3],"plot":2,"purpos":[1,3],"readi":1,"refer":[0,1],"report":1,"seaborn":2,"specif":2,"tabl":1,"templat":[0,1,3],"titleblock":2,"tutori":1,"under":2,"user":2,"walkthrough":2}}) diff --git a/mpl_template/__init__.py b/mpl_template/__init__.py index 31ccd11..7eb5a03 100644 --- a/mpl_template/__init__.py +++ b/mpl_template/__init__.py @@ -1,5 +1,5 @@ from .template import Template, insert_image -__version__ = "0.6.0" +__version__ = "0.7.0" __all__ = ["insert_image", "Template"] diff --git a/mpl_template/template.py b/mpl_template/template.py index 9719739..c3cd6d8 100644 --- a/mpl_template/template.py +++ b/mpl_template/template.py @@ -96,59 +96,50 @@ def _image_path_or_url(path: str) -> Union[str, io.BytesIO]: return str(Path(path).resolve()) -def _apply_exif_rotation(im): +def _apply_exif_rotation(im: Image.Image): """Apply exif rotation tag to a PIL image object Parameters ---------- - im : PIL.Image + im : PIL.Image.Image image object that may contain rotation data Returns ------- - PIL.Image + PIL.Image.Image """ - if TAGS is None or Image is None: # pragma: no cover - raise ImportError("The `pillow` library is required to manipulate images.") - i = im.copy() - - try: - exif = {TAGS.get(tag): value for tag, value in im._getexif().items()} - - # this section adapted from the following SO post: - # https://stackoverflow.com/a/1608846/7486933 - - orientation = exif.get("Orientation") - if orientation == 1: - # Nothing - i = im.copy() - elif orientation == 2: - # Vertical Mirror - i = im.transpose(Transpose.FLIP_LEFT_RIGHT) - elif orientation == 3: - # Rotation 180° - i = im.transpose(Transpose.ROTATE_180) - elif orientation == 4: - # Horizontal Mirror - i = im.transpose(Transpose.FLIP_TOP_BOTTOM) - elif orientation == 5: - # Horizontal Mirror + Rotation 90° CCW - i = im.transpose(Transpose.FLIP_TOP_BOTTOM).transpose(Transpose.ROTATE_90) - elif orientation == 6: - # Rotation 270° - i = im.transpose(Transpose.ROTATE_270) - elif orientation == 7: - # Horizontal Mirror + Rotation 270° - i = im.transpose(Transpose.FLIP_TOP_BOTTOM).transpose(Transpose.ROTATE_270) - elif orientation == 8: - # Rotation 90° - i = im.transpose(Transpose.ROTATE_90) - else: # pragma: no cover - raise Exception("Invalid EXIF Orientation Value") - return i - - except (AttributeError, KeyError, IndexError): + + exif = {TAGS.get(tag): value for tag, value in im.getexif().items()} + + # this section adapted from the following SO post: + # https://stackoverflow.com/a/1608846/7486933 + + orientation = exif.get("Orientation") + if orientation in [None, 1]: return im + if orientation == 2: + # Vertical Mirror + return im.transpose(Transpose.FLIP_LEFT_RIGHT) + if orientation == 3: + # Rotation 180° + return im.transpose(Transpose.ROTATE_180) + if orientation == 4: + # Horizontal Mirror + return im.transpose(Transpose.FLIP_TOP_BOTTOM) + if orientation == 5: + # Horizontal Mirror + Rotation 90° CCW + return im.transpose(Transpose.FLIP_TOP_BOTTOM).transpose(Transpose.ROTATE_90) + if orientation == 6: + # Rotation 270° + return im.transpose(Transpose.ROTATE_270) + if orientation == 7: + # Horizontal Mirror + Rotation 270° + return im.transpose(Transpose.FLIP_TOP_BOTTOM).transpose(Transpose.ROTATE_270) + if orientation == 8: + # Rotation 90° + return im.transpose(Transpose.ROTATE_90) + + raise Exception("Invalid EXIF Orientation Value") # pragma: no cover def insert_image( @@ -233,9 +224,12 @@ def insert_image( kwargs = {"xticks": [], "yticks": [], "zorder": 1} | kwargs - imgaxes = ax.figure.add_axes(ax.get_position(), **kwargs) + imgaxes = ax.figure.add_axes( + ax.get_position(), # type: ignore + **kwargs, + ) bbox = ax.get_window_extent().transformed( - ax.get_figure().dpi_scale_trans.inverted() # type: ignore + ax.get_figure().dpi_scale_trans.inverted(), # type: ignore ) width, height = bbox.width, bbox.height width *= dpi @@ -572,7 +566,7 @@ def add_frame(self): _right = self.right / fwidth _bottom = self.bottom / fheight _top = self.top / fheight - rect = [_left, _bottom, 1 - (_left + _right), 1 - (_bottom + _top)] + rect = (_left, _bottom, 1 - (_left + _right), 1 - (_bottom + _top)) frame = self.fig.add_axes( rect, zorder=100, facecolor="none", xticks=[], yticks=[], label="frame" @@ -633,7 +627,7 @@ def add_titleblock(self): def add_page(self): # pragma: no cover ax = self.fig.add_axes( - [0, 0, 1, 1], + (0, 0, 1, 1), zorder=1000, facecolor="none", xticks=[], @@ -661,7 +655,7 @@ def add_path_text(self): def populate_titleblock(self): for i, (ax, dct) in enumerate( - zip(self.titleblock_axes, self.titleblock_content) + zip(self.titleblock_axes, self.titleblock_content, strict=True) ): assert ax.get_label() == dct.get("name", "b_{}".format(i)), ( "Axes are out of order." diff --git a/mpl_template/tests/test_template.py b/mpl_template/tests/test_template.py index a66d0a2..bb2348b 100644 --- a/mpl_template/tests/test_template.py +++ b/mpl_template/tests/test_template.py @@ -1,10 +1,10 @@ +from importlib.resources import files from pathlib import Path import matplotlib import matplotlib.pyplot as plt import pytest from PIL import Image -from importlib.resources import files from mpl_template import template @@ -40,7 +40,7 @@ def test__apply_exif_rotation(i): im_rot = template._apply_exif_rotation(img) dpi = 96 fig = plt.figure(dpi=dpi, figsize=(im_rot.width / dpi, im_rot.height / dpi)) - ax = fig.add_axes([0, 0, 1, 1]) + ax = fig.add_axes((0, 0, 1, 1)) _ = ax.imshow(im_rot) ax.axis("off") return fig @@ -206,6 +206,19 @@ def test_zero_margins(): return testfig.fig +def test_const_titleblock_elements(): + testfig = template.Template( + figsize=(5, 3), + scriptname="tests.py", + ) + + _ = testfig.blank(with_labels=False) + + n_ax = len(testfig.fig.axes) + _ = testfig.add_titleblock() + assert n_ax == len(testfig.fig.axes) + + @pytest.mark.parametrize( "bad_margin", [ diff --git a/pyproject.toml b/pyproject.toml index 750d6c2..9980c06 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,18 +6,19 @@ build-backend = "setuptools.build_meta" name = "mpl_template" description = "mpl-template: matplotlib report template constructor" readme = "README.md" -requires-python = ">=3.10" -license = { text = "BSD-3-Clause" } +requires-python = ">=3.11" +license = "BSD-3-Clause" +license-files = ["LICENSE"] authors = [{ name = "Austin Orr", email = "austinmartinorr@gmail.com" }] classifiers = [ - "License :: OSI Approved :: BSD License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Intended Audience :: Science/Research", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Intended Audience :: Science/Research", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", ] dependencies = ["matplotlib>=2.5.0"] dynamic = ["version"] @@ -25,16 +26,16 @@ dynamic = ["version"] [project.optional-dependencies] all = ["requests", "pillow"] dev = [ - "mpl-template[all,docs]", - "matplotlib>=3.10,<3.11", # pins mpl & freetype version - "coverage>=6.0.0", - "pytest>=7.0.0", - "pytest-cov>=4.1", - "pytest-mpl>=0.16.0", - "ruff>=0.1.4", - "pre-commit>=3.3", + "mpl-template[all,docs]", + "matplotlib>=3.10,<3.11", # pins mpl & freetype version + "coverage>=6.0.0", + "pytest>=7.0.0", + "pytest-cov>=4.1", + "pytest-mpl>=0.16.0", + "ruff>=0.1.4", + "pre-commit>=3.3", ] -docs = ["sphinx", "nbsphinx", "sphinx-rtd-theme", "seaborn"] +docs = ["sphinx", "nbsphinx", "sphinx-rtd-theme", "seaborn", "ipykernel"] [project.urls] Homepage = "https://github.com/austinorr/mpl-template" @@ -53,7 +54,16 @@ version = { attr = "mpl_template.__version__" } "mpl_template.tests.img" = ["*png", "*jpeg"] [tool.coverage] -source = ["mpl_template"] +run = { branch = true } +report = { show_missing = true } -[tool.coverage.run] -branch = true +[tool.ruff] +lint.select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # pyflakes + "I", # isort + "C", # flake8-comprehensions + "B", # flake8-bugbear + "PERF", # Perflint +] diff --git a/sphinx_docs/source/conf.py b/sphinx_docs/source/conf.py index ec52400..a9dc2b5 100644 --- a/sphinx_docs/source/conf.py +++ b/sphinx_docs/source/conf.py @@ -20,7 +20,7 @@ from mpl_template import __version__ # General information about the project. -project = "mpl-template" +project = f'mpl-template
      v{__version__}' copyright = "2017, Austin Orr" author = "Austin Orr" diff --git a/sphinx_docs/source/notebooks/tutorial/Template_Docs.ipynb b/sphinx_docs/source/notebooks/tutorial/Template_Docs.ipynb index f343d1d..26e0440 100644 --- a/sphinx_docs/source/notebooks/tutorial/Template_Docs.ipynb +++ b/sphinx_docs/source/notebooks/tutorial/Template_Docs.ipynb @@ -17,8 +17,9 @@ "source": [ "import copy\n", "import os\n", - "import matplotlib.pyplot as plt\n", + "\n", "import matplotlib.gridspec as gs\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", "\n", "from mpl_template import Template, insert_image\n", diff --git a/sphinx_docs/source/notebooks/tutorial/img/Facet_Grid.png b/sphinx_docs/source/notebooks/tutorial/img/Facet_Grid.png index 42de8e8..228b360 100644 Binary files a/sphinx_docs/source/notebooks/tutorial/img/Facet_Grid.png and b/sphinx_docs/source/notebooks/tutorial/img/Facet_Grid.png differ