diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f9431db..c7d4bbd 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -16,17 +16,39 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install tox tox-gh-actions - - name: Test with tox - run: tox + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install tox tox-gh-actions + + # Install TeX distribution for PGF output from matplotlib + - name: Install TeX distribution for PGF output (Ubuntu) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y texlive-latex-extra texlive-xetex + + - name: Install TeX distribution for PGF output (Windows) + if: runner.os == 'Windows' + run: | + choco install miktex -y + echo "C:\Program Files\MiKTeX\miktex\bin\x64" >> $env:GITHUB_PATH + + - name: Install TeX distribution for PGF output (macOS) + if: runner.os == 'macOS' + run: | + brew install --cask mactex-no-gui + echo "/Library/TeX/texbin" >> $GITHUB_PATH + + - name: Test with tox + run: tox deploy: needs: build diff --git a/README.rst b/README.rst index b51aaf8..c0a9cd5 100644 --- a/README.rst +++ b/README.rst @@ -270,7 +270,7 @@ Executes a plotting function and saves the resulting plot to specified formats u +----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``teeplot_postprocess`` | Actions to perform after plotting but before saving. Can be a string of code to ``exec`` or a callable function. If a string, it's executed with access to ``plt`` and ``sns`` (if installed), and the plotter return value as ``teed``. | +----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| ``teeplot_save`` | File formats to save the plots in. Defaults to global settings if ``True``, all output suppressed if ``False``. Default global setting is ``{" .png", ".pdf"}``. Supported: ".eps", ".png", ".pdf", ".ps", ".svg". | +| ``teeplot_save`` | File formats to save the plots in. Defaults to global settings if ``True``, all output suppressed if ``False``. Default global setting is ``{" .png", ".pdf"}``. Supported: ".eps", ".png", ".pdf", ".pgf", ".ps", ".svg". | +----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``teeplot_show`` | Dictates whether ``plt.show()`` should be called after plot is saved. If True, the plot is displayed using ``plt.show()``. Default behavior is to display if an interactive environment is detected (e.g., a notebook). | +----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -296,7 +296,7 @@ Environment Variables - ``TEEPLOT_ONCOLLISION``: Configures the default collision handling strategy. See ``teeplot_oncollision`` kwarg - ``TEEPLOT_DRAFTMODE``: If set, enables draft mode globally. -- ``TEEPLOT_``: Boolean flags that determine default behavior for each format (e.g., ``EPS``, ``PNG``, ``PDF``, ``PS``, ``SVG``); "defer" defers to call kwargs. +- ``TEEPLOT_``: Boolean flags that determine default behavior for each format (e.g., ``EPS``, ``PNG``, ``PDF``, ``PGF``, ``PS``, ``SVG``); "defer" defers to call kwargs. Citing ------ diff --git a/teeplot/teeplot.py b/teeplot/teeplot.py index 82e30f2..2409148 100644 --- a/teeplot/teeplot.py +++ b/teeplot/teeplot.py @@ -36,6 +36,7 @@ def _is_running_on_ci() -> bool: save = { ".eps": None, ".pdf": True, + ".pgf": None, ".png": True, ".ps": None, ".svg": None, @@ -338,14 +339,16 @@ def save_callback(): transparent=teeplot_transparent, dpi=teeplot_dpi, # see https://matplotlib.org/2.1.1/users/whats_new.html#reproducible-ps-pdf-and-svg-output - metadata={ - key: None - for key in { - ".png": [], - ".pdf": ["CreationDate"], - ".svg": ["Date"], - }.get(ext, []) - }, + **dict( + metadata={ + key: None + for key in { + ".png": [], + ".pdf": ["CreationDate"], + ".svg": ["Date"], + }.get(ext, []) + }, + ) if ext != ".pgf" else {}, ) if teeplot_show or (teeplot_show is None and hasattr(sys, 'ps1')): diff --git a/tests/test_tee.py b/tests/test_tee.py index b318e63..1f42527 100644 --- a/tests/test_tee.py +++ b/tests/test_tee.py @@ -209,7 +209,7 @@ def test_oncollision_fix(): ) -@pytest.mark.parametrize("format", [".png", ".pdf", ".ps", ".eps", ".svg"]) +@pytest.mark.parametrize("format", [".png", ".pdf", ".pgf", ".ps", ".eps", ".svg"]) def test_outformat(format): # adapted from https://seaborn.pydata.org/generated/seaborn.lineplot.html