Repository: garrettj403/SciencePlots Branch: master Commit: 8d281eabcf5f Files: 62 Total size: 56.7 KB Directory structure: gitextract__3xp0qwg/ ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ └── 01-bug.yml │ └── workflows/ │ ├── pytest.yaml │ └── ruff_check.yaml ├── .gitignore ├── CHANGES.md ├── LICENSE ├── MANIFEST.in ├── README.md ├── examples/ │ └── plot-examples.py ├── pyproject.toml └── src/ └── scienceplots/ ├── __init__.py ├── styles/ │ ├── color/ │ │ ├── bright.mplstyle │ │ ├── discrete-rainbow/ │ │ │ ├── discrete-rainbow-1.mplstyle │ │ │ ├── discrete-rainbow-10.mplstyle │ │ │ ├── discrete-rainbow-11.mplstyle │ │ │ ├── discrete-rainbow-12.mplstyle │ │ │ ├── discrete-rainbow-13.mplstyle │ │ │ ├── discrete-rainbow-14.mplstyle │ │ │ ├── discrete-rainbow-15.mplstyle │ │ │ ├── discrete-rainbow-16.mplstyle │ │ │ ├── discrete-rainbow-17.mplstyle │ │ │ ├── discrete-rainbow-18.mplstyle │ │ │ ├── discrete-rainbow-19.mplstyle │ │ │ ├── discrete-rainbow-2.mplstyle │ │ │ ├── discrete-rainbow-20.mplstyle │ │ │ ├── discrete-rainbow-21.mplstyle │ │ │ ├── discrete-rainbow-22.mplstyle │ │ │ ├── discrete-rainbow-23.mplstyle │ │ │ ├── discrete-rainbow-3.mplstyle │ │ │ ├── discrete-rainbow-4.mplstyle │ │ │ ├── discrete-rainbow-5.mplstyle │ │ │ ├── discrete-rainbow-6.mplstyle │ │ │ ├── discrete-rainbow-7.mplstyle │ │ │ ├── discrete-rainbow-8.mplstyle │ │ │ └── discrete-rainbow-9.mplstyle │ │ ├── high-contrast.mplstyle │ │ ├── high-vis.mplstyle │ │ ├── light.mplstyle │ │ ├── muted.mplstyle │ │ ├── retro.mplstyle │ │ ├── std-colors.mplstyle │ │ └── vibrant.mplstyle │ ├── journals/ │ │ ├── ieee.mplstyle │ │ └── nature.mplstyle │ ├── languages/ │ │ ├── cjk-jp-font.mplstyle │ │ ├── cjk-kr-font.mplstyle │ │ ├── cjk-sc-font.mplstyle │ │ ├── cjk-tc-font.mplstyle │ │ ├── russian-font.mplstyle │ │ └── turkish-font.mplstyle │ ├── misc/ │ │ ├── grid.mplstyle │ │ ├── latex-sans.mplstyle │ │ ├── no-latex.mplstyle │ │ ├── pgf.mplstyle │ │ └── sans.mplstyle │ ├── notebook.mplstyle │ ├── scatter.mplstyle │ └── science.mplstyle ├── styles_discovery.py └── tests/ ├── __init__.py ├── conftest.py └── test_scienceplots.py ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/ISSUE_TEMPLATE/01-bug.yml ================================================ name: Any Report description: File a general purpose report # title: labels: ["bug", "user question/help"] # assignees: body: - type: markdown attributes: value: | Please check it hasn't already been reported in the [issue tracker](../). Thanks for taking the time to fill this out! It really helps us a lot. - type: markdown attributes: value: | First of all, let's have a look to your environment: run the following Python code snippet and paste the output below. ```python import platform import sys import subprocess from importlib.metadata import version print('System: ' + platform.platform()) print('Python: ' + sys.version) print('SciencePlots: ' + version('scienceplots')) print('Matplotlib: ' + version('matplotlib')) print('LaTeX distro:') subprocess.run(["latex", "-v"]) ``` - type: textarea id: env attributes: label: Environment description: Paste here the output of the code above placeholder: | System: Windows-10-10.0.19044-SP0 Python: 3.10.4 (tags/v3.10.4:9d38120, Mar 23 1984, 24:00:00) [MSC v.1929 64 bit (AMD64)] SciencePlots: 0.0.0 Matplotlib: 0.0.0 LaTeX distro: pdfTeX 3.141592653589793238-pi (TeX Live 2022) kpathsea version 6.3.4 Copyright 2022 Han The Thanh (pdfTeX) et al. There is NO warranty. Redistribution of this software is covered by the terms of both the pdfTeX copyright and the Lesser GNU General Public License. For more information about these matters, see the file named COPYING and the pdfTeX source. Primary author of pdfTeX: Han The Thanh (pdfTeX) et al. Compiled with libpng 1.6.37; using libpng 1.6.37 Compiled with zlib 1.2.11; using zlib 1.2.11 Compiled with xpdf version 4.03 CompletedProcess(args=['latex', '-v'], returncode=O) # value: "" render: "Python console" validations: required: true - type: textarea id: styles attributes: label: Affected styles description: > List all styles you are using. Do not miss anyone, they may change the behaviour entirely. placeholder: | ["science", "no-latex"] # value: "" render: "Python console" validations: required: true - type: textarea id: user-description attributes: label: "Describe the issue here" # description: "" placeholder: "What do you expect? What happens?" # value: "" validations: required: true - type: textarea id: how-to-reproduce attributes: label: "How can we replicate it? What have you tried? Please, add a reproducible example" description: "Paste inline code between backticks [`] and code blocks between 3 [```]" placeholder: "Be as accurate as possible, it will help us very much." # value: "" validations: required: true - type: textarea id: extra attributes: label: "Extra info" description: "Please, specify anything else that may be of help (e.g. links to other issues that may be related anywhere, StackOverflow posts, etc.)" # placeholder: "" # value: "" validations: required: false ================================================ FILE: .github/workflows/pytest.yaml ================================================ name: Pytest on: push: branches: [ "master" ] pull_request: branches: [ "master" ] jobs: build: runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.x"] steps: - uses: actions/checkout@v5 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install .[test] sudo apt update sudo apt install dvipng texlive-latex-extra texlive-fonts-recommended cm-super sudo apt install fonts-noto-cjk - name: Test with pytest run: | pytest ================================================ FILE: .github/workflows/ruff_check.yaml ================================================ name: Ruff Check on: push: pull_request: jobs: ruff-lint: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v5 - name: Set up Python uses: actions/setup-python@v6 with: python-version: '3.x' - name: Install dependencies run: | python -m pip install --upgrade pip pip install ruff - name: Run Ruff run: ruff check --output-format=github . ================================================ FILE: .gitignore ================================================ .ipynb_checkpoints/ .DS_STORE SciencePlots.egg-info/ dist/ dev/ TODO.md new-version.md # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover *.py,cover .hypothesis/ .pytest_cache/ cover/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 db.sqlite3-journal # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder .pybuilder/ target/ # Jupyter Notebook .ipynb_checkpoints # IPython profile_default/ ipython_config.py # pyenv # For a library or package, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: # .python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. # However, in case of collaboration, if having platform-specific dependencies or dependencies # having no cross-platform support, pipenv may install dependencies that don't work, or not # install all needed dependencies. #Pipfile.lock # poetry # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. # This is especially recommended for binary packages to ensure reproducibility, and is more # commonly ignored for libraries. # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control #poetry.lock # pdm # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. #pdm.lock # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it # in version control. # https://pdm.fming.dev/#use-with-ide .pdm.toml # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm __pypackages__/ # Celery stuff celerybeat-schedule celerybeat.pid # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ .dmypy.json dmypy.json # Pyre type checker .pyre/ # pytype static type analyzer .pytype/ # Cython debug symbols cython_debug/ # PyCharm # JetBrains specific template is maintained in a separate JetBrains.gitignore that can # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ ================================================ FILE: CHANGES.md ================================================ v2.2.1 (xx-yyy-2026) ==================== Maintenance ----------- - Mitigate packaging issue where styles are not included in local bdist when `.git` folder is not present. Affected users exclusively are those building the wheel by themselves from a version repo source file, e.g., via AUR. See issue 151: https://github.com/garrettj403/SciencePlots/issues/151 v2.2.0 (20-Nov-2025) ==================== New features ------------ - Fix `['science', 'no-latex']` font does not work with symbols (e.g. degree symbol) This style set was found to be incompatible with _Cartopy_. - Add all 23 "discrete rainbow" styles proposed by Paul Tol on his website (by @IchBinGROOT) Access them with the style names `discrete-rainbow-1`, `discrete-rainbow-2`, ..., `discrete-rainbow-23` - Update `README.md` to reflect that _Install from `conda-forge` is now available!_ Maintenance ----------- - Update Paul Tol's webpage link to https://sronpersonalpages.nl/~pault/ in relevant comments through the project. - Improve `turkish-font.mplstyle` (may add some breaking changes) 1. `:` and `!` are now interpreted as text by default, not as control characters. 2. Assume UTF-8 encoding by default. 3. Enhance compatibility, especially with T1 font encoding, by using the package `lmodern`. - Now all subdirectories of the ``styles`` folder are parsed for styles, instead of just the first two levels. - Upgrade & unify issue templates. v2.1.1 (25-Nov-2023) ==================== - Avoid Matplotlib issuing `INFO` log statements about no available fonts due to last release changes. - Add `science` + `no-latex ` example v2.1.0 (30-May-2023) ==================== - Change `science` and `ieee` to use Times New Roman look-alike fonts - Tweak `plot-examples.py` and clean PDF output v2.0.1 (03-Dec-2022) ==================== - Add Turkish `turkish-font` language style v2.0.0 (21-Nov-2022) ==================== - Fix import on case sensitive OSs - Finally bump to this version, following breaking change of distribution v1.1.0 (07-Nov-2022) ==================== - Major change in distribution system - Now needs import directive `import scienceplots` - Fix not using raw string in `plot-example.py` - Update README v1.0.9 (16-Sep-2021) ==================== - `notebook`: - make Latex fonts sans-serif - Fix bug with Latex packages: - e.g., `\usepackage{amsmath, amssymb, sfmath}` --> `\usepackage{amsmath} \usepackage{amssymb} \usepackage{sfmath}` - Add `pyproject.toml` file (see PEP 517/518) - Minor updates to README, including adding more papers to publication list v1.0.8 (02-Jun-2021) ==================== - ``nature``: - Added style for Nature articles - Uses sans-serif fonts - ``latex-sans``: - Added style for using LaTeX with sans-serif fonts - ``std-colors``: - Added style to recover the standard color cycle of the SciencePlots package - For example, if you use ``plt.style.use(["science", "ieeee"]). The figure will use the ``"ieee"`` color cycle. To revert to the standard color cycle, you can use ``plt.style.use(["science", "ieee", "std-colors"])``. - ``science``: - Added ``amssymb`` to LaTeX preamble - ``grid``: - Set ``axes.axisbelow`` to True - Minor updates to README v1.0.7 (28-Feb-2021) ==================== - Add support for CJK fonts: - see README for details - Add example of CJK fonts: - see Fig 14a, Fig 14b, Fig 14c, Fig 14d - ``science`` style: - use default serif font - ``ieee`` style: - use Times font - ``grid`` style: - change line style to '--' - README: - add badge for Zenodo reference - add info on citing SciencePlots - add info on using Times New Roman - add more papers using SciencePlots v1.0.6 (19-Oct-2020) ==================== - The main reason for this release is to trigger Zenodo: - I've added SciencePlots to Zenodo (an archiving service). - It only archives after new releases, so I will make a trivial version bump. - Trivial changes to README: - Added installation info for Google Colab, Jupyter Notebooks, etc. - Added PyPI badge - Added more papers to list v1.0.5 (8-Sep-2020) =================== - New color blind safe color cycles (``high-contrast.mplstyle``, ``light.mplstyle``). Taken from [Paul Tol's website](https://personal.sron.nl/~pault/). - Fixed color order in ``muted.mplstyle``, ``vibrant.mplstyle``, and ``bright.mplstyle``. v1.0.4 (14-Aug-2020) ==================== - New style: ``grid`` - this will add grid lines - ``science`` style: - use a serif font with mathtex - README: - Add example of the ``notebook`` style - Add FAQ - Update publications - Other misc changes... ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2018 John Garrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: MANIFEST.in ================================================ # https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html#controlling-files-in-the-distribution (accessed on 2026-02-20) # By default 'setuptools_scm' includes all git-tracked files (all .py files are included by default by 'setuptools') # In sdist downloads, .git is non existent. Ref: https://github.com/garrettj403/SciencePlots/issues/151 # Required data files are exhaustively listed here: recursive-include src/scienceplots/styles *.mplstyle include CHANGES.md include LICENSE include MANIFEST.in include pyproject.toml include README.md # Clean unnecessary files in source distribution: prune .github prune .git prune examples ================================================ FILE: README.md ================================================ Science Plots =============

PyPI version PyPI version
conda-forge version conda-forge version
DOI DOI

> **Warning** > : As of version 2.0.0, you need to add `import scienceplots` before setting the style (`plt.style.use('science')`). *Matplotlib styles for scientific figures* This repo has Matplotlib styles to format your figures for scientific papers, presentations and theses.

You can find [the full gallery of included styles here](https://github.com/garrettj403/SciencePlots/wiki/Gallery). Getting Started --------------- The easiest way to install SciencePlots is by using `pip`: ```bash # to install the latest release (from PyPI) pip install SciencePlots # to install the latest release (using Conda) conda install -c conda-forge scienceplots # to install the latest commit (from GitHub) pip install git+https://github.com/garrettj403/SciencePlots # to clone and install from a local copy git clone https://github.com/garrettj403/SciencePlots.git cd SciencePlots pip install -e . ``` From version `v1.1.0` on, `import scienceplots` is needed on top of your scripts so Matplotlib can make use of the styles. **Notes:** - SciencePlots requires Latex ([see Latex installation instructions](https://github.com/garrettj403/SciencePlots/wiki/FAQ#installing-latex)). - If you would like to use CJK fonts, you will need to install these font separately ([see CJK font installation instructions](https://github.com/garrettj403/SciencePlots/wiki/FAQ#installing-cjk-fonts)). Please see the [FAQ](https://github.com/garrettj403/SciencePlots/wiki/FAQ) for more information and troubleshooting. Using the Styles ---------------- ``"science"`` is the primary style in this repo. Whenever you want to use it, simply add the following to the top of your python script: ```python import matplotlib.pyplot as plt import scienceplots plt.style.use('science') ``` You can also combine multiple styles together by: ```python plt.style.use(['science','ieee']) ``` In this case, the ``ieee`` style will override some of the parameters from the ``science`` style in order to configure the plot for IEEE papers (column width, fontsizes, etc.). To use any of the styles temporarily, you can use: ```python with plt.style.context('science'): plt.figure() plt.plot(x, y) plt.show() ``` Examples -------- The basic ``science`` style is shown below: It can be cascaded with other styles to fine-tune the appearance. For example, the ``science`` + ``notebook`` styles (intended for Jupyter notebooks): Please see [the project Wiki](https://github.com/garrettj403/SciencePlots/wiki/Gallery) for a full list of available styles. Specific Styles for Academic Journals ------------------------------------- The ``science`` + ``ieee`` styles for IEEE papers: - IEEE requires figures to be readable when printed in black and white. The ``ieee`` style also sets the figure width to fit within one column of an IEEE paper. The ``science`` + ``nature`` styles for Nature articles: - Nature recommends sans-serif fonts. Other languages --------------- SciencePlots currently supports: * [Traditional Chinese](https://github.com/garrettj403/SciencePlots/wiki/Gallery#traditional-chinese) * [Simplified Chinese](https://github.com/garrettj403/SciencePlots/wiki/Gallery#simplified-chinese) * [Japanese](https://github.com/garrettj403/SciencePlots/wiki/Gallery#japanese) * [Korean](https://github.com/garrettj403/SciencePlots/wiki/Gallery#korean) * [Russian](https://github.com/garrettj403/SciencePlots/wiki/Gallery#russian) * [Turkish](https://github.com/garrettj403/SciencePlots/wiki/Gallery#turkish) Example: Traditional Chinese (`science` + `no-latex` + `cjk-tc-font`): See the [FAQ](https://github.com/garrettj403/SciencePlots/wiki/FAQ#installing-cjk-fonts) for information on installing CJK fonts. Other color cycles ------------------ SciencePlots comes with a variety of different color cycles. For a full list, [see the project Wiki](https://github.com/garrettj403/SciencePlots/wiki/Gallery#color-cycles). Two examples are shown below. The ``bright`` color cycle (color blind safe): The ``high-vis`` color cycle: Paul Tol's discrete rainbow color sets are available as well, with the style identifier ``discrete-rainbow-``, where ```` is the number of unique colors. ```` ranges from ``1`` to ``23`` (inclusive). For example, ``discrete-rainbow-15``: Help and Contributing --------------------- Please feel free to contribute to the SciencePlots repo! For example, it would be good to add new styles for different journals and add new color cycles. Before starting a new style or making any changes, please create an issue through the [GitHub issue tracker](https://github.com/garrettj403/SciencePlots/issues). That way we can discuss if the changes are necessary and the best approach. If you need any help with SciencePlots, please first check the [FAQ](https://github.com/garrettj403/SciencePlots/wiki/FAQ) and search through the [previous GitHub issues](https://github.com/garrettj403/SciencePlots/issues). If you can't find an answer, create a new issue through the [GitHub issue tracker](https://github.com/garrettj403/SciencePlots/issues). You can checkout [Matplotlib's documentation](https://matplotlib.org/tutorials/introductory/customizing.html) for more information on plotting settings. FAQ --- You can find [the FAQ in the project Wiki.](https://github.com/garrettj403/SciencePlots/wiki/FAQ) SciencePlots in Academic Papers ------------------------------- The following papers use ``SciencePlots``: - C.-S. Li, S.-P. Ma, and T.-H. Lin, ["FMSA: A Universal Microservice Architecture Based on FHIR Medical Informatics Standard,"](https://ieeexplore.ieee.org/document/11326732) 2025 Second International Conference on Artificial Intelligence for Medicine, Health and Care (AIxMHC), pp. 42–49, Oct. 2025. - Keçeci, Mehmet. "Scalable Complexity: Mathematical Analysis and Potential for Physical Applications of the Keçeci Circle Fractal", 13 May 2025. https://doi.org/10.5281/zenodo.15396198. (Reference has been made to the module "SciencePlots".) - J. D. Garrett, C.-Y. E. Tong, L. Zeng, T.-J. Chen and M.-J. Wang, ["A 345 GHz Sideband-Separating Receiver Prototype with Ultra-Wide Instantaneous Bandwidth,"](https://ieeexplore.ieee.org/document/10089556) *IEEE Trans. THz Sci. Technol.*, vol. 13, no. 3, pp. 237-245, Mar. 2023. - J. Garrett, B.-K. Tan, C. Chaumont, F. Boussaha, and G. Yassin, ["A 230-GHz Endfire SIS Mixer With Near Quantum-Limited Performance,"](https://ieeexplore.ieee.org/document/9833810) *IEEE Microw. Wirel. Compon. Lett.*, Jul. 2022. ([open access](https://ora.ox.ac.uk/objects/uuid:59a100bf-c997-499a-be20-01fc66fffe2b)) - J. Garrett, and E. Tong, ["Measuring Cryogenic Waveguide Loss in the Terahertz Regime,"](https://ieeexplore.ieee.org/document/9727077) *IEEE Trans. THz Sci. Technol.*, vol. 12, no. 3, pp. 293-299, May 2022. - Y. Liu, X. Liu, and Y. Sun, ["QGrain: An open-source and easy-to-use software for the comprehensive analysis of grain size distributions"](https://doi.org/10.1016/j.sedgeo.2021.105980), *Sedimentary Geology*, vol. 423, 105980, Aug. 2021. - M. Gasanov, *et al.*, ["A New Multi-objective Approach to Optimize Irrigation Using a Crop Simulation Model and Weather History"](https://link.springer.com/chapter/10.1007/978-3-030-77970-2_7) in *Computational Science–ICCS 2021*, Krakow, Poland, Jun. 2021, pp. 75-88. ([open access](https://www.researchgate.net/profile/Sergey-Matveev-5/publication/352285985_A_New_Multi-objective_Approach_to_Optimize_Irrigation_Using_a_Crop_Simulation_Model_and_Weather_History/links/60e74b88b8c0d5588ce2da07/A-New-Multi-objective-Approach-to-Optimize-Irrigation-Using-a-Crop-Simulation-Model-and-Weather-History.pdf)) - J. Garrett, and E. Tong, ["A Dispersion-Compensated Algorithm for the Analysis of Electromagnetic Waveguides,"](https://ieeexplore.ieee.org/document/9447194) *IEEE Signal Process. Lett.*, vol. 28, pp. 1175-1179, Jun. 2021. - G. Jegannathan, *et al.*, ["Current-Assisted SPAD with Improved p-n Junction and Enhanced NIR Performance"](https://www.mdpi.com/1424-8220/20/24/7105), *Sensors*, Dec 2020. ([open access](https://www.mdpi.com/1424-8220/20/24/7105)) - H. Tian, *et al.*, ["ivis Dimensionality Reduction Framework for Biomacromolecular Simulations"](https://pubs.acs.org/doi/abs/10.1021/acs.jcim.0c00485), *J. Chem. Inf. Model.*, Aug 2020. ([open access](https://arxiv.org/pdf/2004.10718.pdf)) - P. Stoltz, *et al.*, ["A new simple algorithm for space charge limited emission,"](https://aip.scitation.org/doi/10.1063/5.0020781) *Phys. Plasmas*, vol. 27, no. 9, pp. 093103, Sep. 2020. ([open access](https://aip.scitation.org/doi/10.1063/5.0020781)) - J. Garrett, *et al.*, ["A Nonlinear Transmission Line Model for Simulating Distributed SIS Frequency Multipliers,"](https://ieeexplore.ieee.org/abstract/document/9050728) *IEEE Trans. THz Sci. Technol.*, vol. 10, no. 3, pp. 246-255, May 2020. ([open access](https://ora.ox.ac.uk/objects/uuid:5ca31c2c-a984-462c-b21a-3fe16eee0d9b/download_file?safe_filename=XXXX_final_JohnGarrett.pdf&type_of_work=Journal+article)) - J. Garrett, *et al.*, ["Simulating the Behavior of a 230 GHz SIS Mixer Using Multi-Tone Spectral Domain Analysis,"](https://ieeexplore.ieee.org/document/8822760/) *IEEE Trans. THz Sci. Technol.*, vol. 9, no. 9, pp. 540-548, Nov. 2019. ([open access](https://ora.ox.ac.uk/objects/uuid:0fd4537d-258c-454a-bbfb-09b1bcd88d49/download_file?file_format=pdf&safe_filename=XXXX_final.pdf&type_of_work=Journal+article)) - J. Garrett, *et al.*, ["A Compact and Easy to Fabricate E-plane Waveguide Bend,"](https://ieeexplore.ieee.org/document/8760521) *IEEE Microw. Wireless Compon. Lett.*, vol. 29, no. 8, pp. 529-531, Aug. 2019. ([open access](https://ora.ox.ac.uk/objects/uuid:496855f9-be2a-47cd-b498-1753d8033f50/download_file?file_format=pdf&safe_filename=Waveguide_Bend__IEEE_MWCL_.pdf&type_of_work=Journal+article)) - J. Garrett, ["A 230 GHz Focal Plane Array Using a Wide IF Bandwidth SIS Receiver,"](https://ora.ox.ac.uk/objects/uuid:d47fbf3b-1cf3-4e58-be97-767b9893066e/download_file?file_format=pdf&safe_filename=GarrettJ_DPhilThesis.pdf&type_of_work=Thesis) DPhil thesis, University of Oxford, Oxford, UK, 2018. ([open access](https://ora.ox.ac.uk/objects/uuid:d47fbf3b-1cf3-4e58-be97-767b9893066e/download_file?file_format=pdf&safe_filename=GarrettJ_DPhilThesis.pdf&type_of_work=Thesis)) If you use ``SciencePlots`` in your paper/thesis, feel free to add it to the list! Citing SciencePlots ------------------- You don't have to cite SciencePlots if you use it but it's nice if you do: @article{SciencePlots, author = {John D. Garrett}, title = {{garrettj403/SciencePlots}}, month = sep, year = 2021, publisher = {Zenodo}, version = {1.0.9}, doi = {10.5281/zenodo.4106649}, url = {http://doi.org/10.5281/zenodo.4106649} } ================================================ FILE: examples/plot-examples.py ================================================ """Plot examples of SciencePlot styles.""" # %% import numpy as np import matplotlib.pyplot as plt import scienceplots # noqa: F401 import os # Check we are in examples dir current_dir = os.getcwd().lower() if current_dir.endswith("scienceplots"): os.chdir("./examples") # Create 'figures' folder if it does not exist if not os.path.exists("./figures"): os.makedirs("figures") def model(x, p): return x ** (2 * p + 1) / (1 + x ** (2 * p)) pparam = dict(xlabel="Voltage (mV)", ylabel=r"Current ($\mu$A)") x = np.linspace(0.75, 1.25, 201) # %% # Style 'science' with plt.style.context(["science"]): fig, ax = plt.subplots() for p in [10, 15, 20, 30, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig01a.jpg", dpi=300) plt.close() # %% # Styles 'science', 'no-latex' with plt.style.context(["science", "no-latex"]): fig, ax = plt.subplots() for p in [10, 15, 20, 30, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig01b.jpg", dpi=300) plt.close() # %% # Styles 'science', 'ieee' with plt.style.context(["science", "ieee"]): fig, ax = plt.subplots() for p in [10, 20, 40, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig02a.jpg", dpi=300) plt.close() # %% # Styles 'science', 'ieee', 'std-colors' with plt.style.context(["science", "ieee", "std-colors"]): fig, ax = plt.subplots() for p in [10, 15, 20, 30, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig02b.jpg", dpi=300) plt.close() # %% # Styles 'science', 'nature' with plt.style.context(["science", "nature"]): fig, ax = plt.subplots() for p in [10, 15, 20, 30, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig02c.jpg", dpi=300) plt.close() # %% # Styles 'science', 'scatter' with plt.style.context(["science", "scatter"]): fig, ax = plt.subplots(figsize=(4, 4)) ax.plot([-2, 2], [-2, 2], "k--") ax.fill_between( [-2, 2], [-2.2, 1.8], [-1.8, 2.2], color="dodgerblue", alpha=0.2, lw=0 ) for i in range(7): x1 = np.random.normal(0, 0.5, 10) y1 = x1 + np.random.normal(0, 0.2, 10) ax.plot(x1, y1, label=r"$^\#${}".format(i + 1)) lgd = r"$\mathring{P}=\begin{cases}1&\text{if $\nu\geq0$}\\0&\text{if $\nu<0$}\end{cases}$" ax.legend(title=lgd, loc=2, ncol=2) xlbl = r"$\log_{10}\left(\frac{L_\mathrm{IR}}{\mathrm{L}_\odot}\right)$" ylbl = r"$\log_{10}\left(\frac{L_\circledast}{\mathrm{L}_\odot}\right)$" ax.set_xlabel(xlbl) ax.set_ylabel(ylbl) ax.set_xlim([-2, 2]) ax.set_ylim([-2, 2]) fig.savefig("figures/fig03.jpg", dpi=300) plt.close() # %% # Styles 'science', 'high-vis' with plt.style.context(["science", "high-vis"]): fig, ax = plt.subplots() for p in [10, 15, 20, 30, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig04.jpg", dpi=300) plt.close() # %% # Styles 'dark_background', 'science', 'high-vis' with plt.style.context(["dark_background", "science", "high-vis"]): fig, ax = plt.subplots() for p in [10, 15, 20, 30, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig05.jpg", dpi=300) plt.close() # %% # Styles 'science', 'notebook' with plt.style.context(["science", "notebook"]): fig, ax = plt.subplots() for p in [10, 15, 20, 30, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig10.jpg", dpi=300) plt.close() # %% # Plot different color cycles # %% # Styles 'science', 'bright' with plt.style.context(["science", "bright"]): fig, ax = plt.subplots() for p in [5, 10, 15, 20, 30, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig06.jpg", dpi=300) plt.close() # %% # Styles 'science', 'vibrant' with plt.style.context(["science", "vibrant"]): fig, ax = plt.subplots() for p in [5, 10, 15, 20, 30, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig07.jpg", dpi=300) plt.close() # %% # Styles 'science', 'muted' with plt.style.context(["science", "muted"]): fig, ax = plt.subplots() for p in [5, 7, 10, 15, 20, 30, 38, 50, 100, 500]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order", fontsize=7) ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig08.jpg", dpi=300) plt.close() # %% # Styles 'science', 'retro' with plt.style.context(["science", "retro"]): fig, ax = plt.subplots() for p in [10, 15, 20, 30, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig09.jpg", dpi=300) plt.close() # %% # Styles 'science', 'grid' with plt.style.context(["science", "grid"]): fig, ax = plt.subplots() for p in [10, 15, 20, 30, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig11.jpg", dpi=300) plt.close() # %% # Styles 'science', 'high-contrast' with plt.style.context(["science", "high-contrast"]): fig, ax = plt.subplots() for p in [10, 20, 50]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order") ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig12.jpg", dpi=300) plt.close() # %% # Styles 'science', 'light' with plt.style.context(["science", "light"]): fig, ax = plt.subplots() for p in [5, 7, 10, 15, 20, 30, 38, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order", fontsize=7) ax.autoscale(tight=True) ax.set(**pparam) fig.savefig("figures/fig13.jpg", dpi=300) plt.close() # %% # Styles for CJK languages # Note: You need to install the Noto Serif CJK Fonts before running # examples 14 and 15. See FAQ in README. # %% # Styles 'science', 'no-latex', 'cjk-*-font' with plt.style.context(["science", "no-latex", "cjk-tc-font"]): fig, ax = plt.subplots() for p in [5, 7, 10, 15, 20, 30, 38, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order", fontsize=7) ax.set(xlabel=r"電壓 (mV)") ax.set(ylabel=r"電流 ($\mu$A)") ax.autoscale(tight=True) fig.savefig("figures/fig14a.jpg", dpi=300) plt.close() with plt.style.context(["science", "no-latex", "cjk-sc-font"]): fig, ax = plt.subplots() for p in [5, 7, 10, 15, 20, 30, 38, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order", fontsize=7) ax.set(xlabel=r"电压 (mV)") ax.set(ylabel=r"电流 ($\mu$A)") ax.autoscale(tight=True) fig.savefig("figures/fig14b.jpg", dpi=300) plt.close() with plt.style.context(["science", "no-latex", "cjk-jp-font"]): fig, ax = plt.subplots() for p in [5, 7, 10, 15, 20, 30, 38, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order", fontsize=7) ax.set(xlabel=r"電圧 (mV)") ax.set(ylabel=r"電気 ($\mu$A)") ax.autoscale(tight=True) fig.savefig("figures/fig14c.jpg", dpi=300) plt.close() with plt.style.context(["science", "no-latex", "cjk-kr-font"]): fig, ax = plt.subplots() for p in [5, 7, 10, 15, 20, 30, 38, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title="Order", fontsize=7) ax.set(xlabel=r"전압 (mV)") ax.set(ylabel=r"전류 ($\mu$A)") ax.autoscale(tight=True) fig.savefig("figures/fig14d.jpg", dpi=300) plt.close() # import matplotlib # matplotlib.use('pgf') # stwich backend to pgf # matplotlib.rcParams.update({ # "pgf.preamble": [ # "\\usepackage{fontspec}", # '\\usepackage{xeCJK}', # r'\setmainfont{Times New Roman}', # EN fonts Romans # r'\setCJKmainfont{SimHei}', # set CJK fonts as SimSun # r'\setCJKsansfont{SimHei}', # r'\newCJKfontfamily{\Song}{SimSun}', # ] # }) # with plt.style.context(['science', 'cjk-tc-font']): # fig, ax = plt.subplots() # for p in [5, 7, 10, 15, 20, 30, 38, 50, 100]: # ax.plot(x, model(x, p), label=p) # ax.legend(title='Order', fontsize=7) # ax.set(xlabel=r'電壓 (mV)') # ax.set(ylabel=r'電流 ($\mu$A)') # ax.autoscale(tight=True) # fig.savefig('figures/fig15.pdf', backend='pgf') # plt.close() # %% # Styles 'science', 'russian-font' with plt.style.context(["science", "russian-font"]): fig, ax = plt.subplots() for p in [5, 7, 10, 15, 20, 30, 38, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title=r"Число", fontsize=7) ax.set(xlabel=r"Напряжение (mV)") ax.set(ylabel=r"Сила тока ($\mu$A)") ax.autoscale(tight=True) fig.savefig("figures/fig16.jpg", dpi=300) plt.close() # %% # Styles 'science', 'turkish-font' with plt.style.context(["science", "turkish-font"]): fig, ax = plt.subplots() for p in [5, 7, 10, 15, 20, 30, 38, 50, 100]: ax.plot(x, model(x, p), label=p) ax.legend(title=r"Düzen", fontsize=7) ax.set(xlabel=r"Gerilim/Volt (mV)") ax.set(ylabel=r"Mevcut Güç/Akım ($\mu$A)") ax.autoscale(tight=True) fig.savefig("figures/fig17.jpg", dpi=300) plt.close() # %% # Styles 'science', 'no-latex', 'discrete-rainbow-*' # Plot all discrete-rainbow styles p_list = np.logspace(0, 2, 23) for index in range(1, 23 + 1): style_name = f"discrete-rainbow-{index}" figure_name = f"fig_dr_{index}.jpg" with plt.style.context(["science", "no-latex", style_name]): fig, ax = plt.subplots() for p in p_list[: index]: ax.plot(x, model(x, p)) ax.autoscale(tight=True) ax.set(**pparam) fig.savefig(f"figures/{figure_name}", dpi=300) plt.close() # %% ================================================ FILE: pyproject.toml ================================================ [build-system] requires = ["setuptools>=77", "setuptools_scm>=8"] build-backend = "setuptools.build_meta" [project] name = "SciencePlots" authors = [{ name = "John Garrett", email = "garrettj403@gmail.com" }] maintainers = [{ name = "Echedey Luis", email = "echelual@gmail.com" }] description = "Format Matplotlib for scientific plotting" readme = { file = "README.md", content-type = "text/markdown" } license = "MIT" license-files = ["LICENSE"] keywords = [ "matplotlib-style-sheets", "matplotlib-figures", "scientific-papers", "thesis-template", "matplotlib-styles", "python", ] classifiers = [ "Development Status :: 6 - Mature", "Intended Audience :: Science/Research", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering :: Visualization", "Framework :: Matplotlib", ] dynamic = ["version"] requires-python = ">=3.8" dependencies = ["matplotlib"] [project.optional-dependencies] test = ["pytest", "numpy"] all = ["SciencePlots[test]"] [project.urls] Homepage = "https://github.com/garrettj403/SciencePlots/wiki" Documentation = "https://github.com/garrettj403/SciencePlots/wiki" Repository = "https://github.com/garrettj403/SciencePlots" Issues = "https://github.com/garrettj403/SciencePlots/issues" Changelog = "https://github.com/garrettj403/SciencePlots/blob/master/CHANGES.md" [tool.setuptools_scm] # blank section to avoid warning [tool.pytest.ini_options] addopts = "-ra" testpaths = ["scienceplots/tests"] [tool.ruff] # Same as Black. line-length = 88 indent-width = 4 # Exclude annotations and type comments lint.ignore = ["ANN"] ================================================ FILE: src/scienceplots/__init__.py ================================================ import os # pathlib.Path.walk not available in Python <3.12 import matplotlib.pyplot as plt import scienceplots from .styles_discovery import read_styles_in_folders # register the bundled stylesheets in the matplotlib style library scienceplots_path = scienceplots.__path__[0] styles_path = os.path.join(scienceplots_path, "styles") # Reads styles in /styles folder and all subfolders stylesheets = read_styles_in_folders(styles_path) # Update dictionary of styles - plt.style.library plt.style.core.update_nested_dict(plt.style.library, stylesheets) # Update `plt.style.available`, copy-paste from: # https://github.com/matplotlib/matplotlib/blob/a170539a421623bb2967a45a24bb7926e2feb542/lib/matplotlib/style/core.py#L266 # noqa: E501 plt.style.core.available[:] = sorted(plt.style.library.keys()) ================================================ FILE: src/scienceplots/styles/color/bright.mplstyle ================================================ # Bright color scheme # color-blind safe # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['4477AA', 'EE6677', '228833', 'CCBB44', '66CCEE', 'AA3377', 'BBBBBB']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-1.mplstyle ================================================ # Discrete rainbow color scheme with 1 color # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['1965B0']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-10.mplstyle ================================================ # Discrete rainbow color scheme with 10 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['882E72', '1965B0', '7BAFDE', '4EB265', 'CAE0AB', 'F7F056', 'F4A736', 'E8601C', 'DC050C', '72190E']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-11.mplstyle ================================================ # Discrete rainbow color scheme with 11 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['882E72', '1965B0', '5289C7', '7BAFDE', '4EB265', 'CAE0AB', 'F7F056', 'F4A736', 'E8601C', 'DC050C', '72190E']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-12.mplstyle ================================================ # Discrete rainbow color scheme with 12 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['D1BBD7', 'AE76A3', '882E72', '1965B0', '5289C7', '7BAFDE', '4EB265', 'CAE0AB', 'F7F056', 'F4A736', 'E8601C', 'DC050C']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-13.mplstyle ================================================ # Discrete rainbow color scheme with 13 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['D1BBD7', 'AE76A3', '882E72', '1965B0', '5289C7', '7BAFDE', '4EB265', '90C987', 'CAE0AB', 'F7F056', 'F4A736', 'E8601C', 'DC050C']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-14.mplstyle ================================================ # Discrete rainbow color scheme with 14 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['D1BBD7', 'AE76A3', '882E72', '1965B0', '5289C7', '7BAFDE', '4EB265', '90C987', 'CAE0AB', 'F7F056', 'F6C141', 'F1932D', 'E8601C', 'DC050C']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-15.mplstyle ================================================ # Discrete rainbow color scheme with 15 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['D1BBD7', 'AE76A3', '882E72', '1965B0', '5289C7', '7BAFDE', '4EB265', '90C987', 'CAE0AB', 'F7F056', 'F6C141', 'F1932D', 'E8601C', 'DC050C', '72190E']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-16.mplstyle ================================================ # Discrete rainbow color scheme with 16 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['D1BBD7', 'BA8DB4', 'AA6F9E', '882E72', '1965B0', '5289C7', '7BAFDE', '4EB265', '90C987', 'CAE0AB', 'F7F056', 'F6C141', 'F1932D', 'E8601C', 'DC050C', '72190E']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-17.mplstyle ================================================ # Discrete rainbow color scheme with 17 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['D1BBD7', 'BA8DB4', 'AA6F9E', '994F88', '882E72', '1965B0', '5289C7', '7BAFDE', '4EB265', '90C987', 'CAE0AB', 'F7F056', 'F6C141', 'F1932D', 'E8601C', 'DC050C', '72190E']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-18.mplstyle ================================================ # Discrete rainbow color scheme with 18 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['D1BBD7', 'BA8DB4', 'AA6F9E', '994F88', '882E72', '1965B0', '5289C7', '7BAFDE', '4EB265', '90C987', 'CAE0AB', 'F7F056', 'F6C141', 'F1932D', 'E8601C', 'DC050C', 'A5170E', '72190E']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-19.mplstyle ================================================ # Discrete rainbow color scheme with 19 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['D9CCE3', 'CAACCB', 'BA8DB4', 'AA6F9E', '994F88', '882E72', '1965B0', '5289C7', '7BAFDE', '4EB265', '90C987', 'CAE0AB', 'F7F056', 'F6C141', 'F1932D', 'E8601C', 'DC050C', 'A5170E', '72190E']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-2.mplstyle ================================================ # Discrete rainbow color scheme with 2 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['1965B0', 'DC050C']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-20.mplstyle ================================================ # Discrete rainbow color scheme with 20 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['D9CCE3', 'CAACCB', 'BA8DB4', 'AA6F9E', '994F88', '882E72', '1965B0', '437DBF', '6195CF', '7BAFDE', '4EB265', '90C987', 'CAE0AB', 'F7F056', 'F6C141', 'F1932D', 'E8601C', 'DC050C', 'A5170E', '72190E']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-21.mplstyle ================================================ # Discrete rainbow color scheme with 21 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['D9CCE3', 'CAACCB', 'BA8DB4', 'AA6F9E', '994F88', '882E72', '1965B0', '437DBF', '6195CF', '7BAFDE', '4EB265', '90C987', 'CAE0AB', 'F7F056', 'F7CB45', 'F4A736', 'EE8026', 'E65518', 'DC050C', 'A5170E', '72190E']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-22.mplstyle ================================================ # Discrete rainbow color scheme with 22 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['D9CCE3', 'CAACCB', 'BA8DB4', 'AA6F9E', '994F88', '882E72', '1965B0', '437DBF', '6195CF', '7BAFDE', '4EB265', '90C987', 'CAE0AB', 'F7F056', 'F7CB45', 'F4A736', 'EE8026', 'E65518', 'DC050C', 'A5170E', '72190E', '42150A']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-23.mplstyle ================================================ # Discrete rainbow color scheme with 23 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['E8ECFB', 'D9CCE3', 'CAACCB', 'BA8DB4', 'AA6F9E', '994F88', '882E72', '1965B0', '437DBF', '6195CF', '7BAFDE', '4EB265', '90C987', 'CAE0AB', 'F7F056', 'F7CB45', 'F4A736', 'EE8026', 'E65518', 'DC050C', 'A5170E', '72190E', '42150A']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-3.mplstyle ================================================ # Discrete rainbow color scheme with 3 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['1965B0', 'F7F056', 'DC050C']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-4.mplstyle ================================================ # Discrete rainbow color scheme with 4 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['1965B0', '4EB265', 'F7F056', 'DC050C']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-5.mplstyle ================================================ # Discrete rainbow color scheme with 5 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['1965B0', '7BAFDE', '4EB265', 'F7F056', 'DC050C']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-6.mplstyle ================================================ # Discrete rainbow color scheme with 6 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['1965B0', '7BAFDE', '4EB265', 'CAE0AB', 'F7F056', 'DC050C']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-7.mplstyle ================================================ # Discrete rainbow color scheme with 7 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['882E72', '1965B0', '7BAFDE', '4EB265', 'CAE0AB', 'F7F056', 'DC050C']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-8.mplstyle ================================================ # Discrete rainbow color scheme with 8 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['882E72', '1965B0', '7BAFDE', '4EB265', 'CAE0AB', 'F7F056', 'EE8026', 'DC050C']) ================================================ FILE: src/scienceplots/styles/color/discrete-rainbow/discrete-rainbow-9.mplstyle ================================================ # Discrete rainbow color scheme with 9 colors # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['882E72', '1965B0', '7BAFDE', '4EB265', 'CAE0AB', 'F7F056', 'EE8026', 'DC050C', '72190E']) ================================================ FILE: src/scienceplots/styles/color/high-contrast.mplstyle ================================================ # High-contrast color scheme # color-blind safe # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['004488', 'DDAA33', 'BB5566']) ================================================ FILE: src/scienceplots/styles/color/high-vis.mplstyle ================================================ # Matplotlib style for high visability plots (i.e., bright colors!!!) # Set color cycle axes.prop_cycle : (cycler('color', ["0d49fb", "e6091c", "26eb47", "8936df", "fec32d", "25d7fd"]) + cycler('ls', ['-', '--', '-.', ':', '-', '--'])) ================================================ FILE: src/scienceplots/styles/color/light.mplstyle ================================================ # Light color scheme # color-blind safe # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['77AADD', 'EE8866', 'EEDD88', 'FFAABB', '99DDFF', '44BB99', 'BBCC33', 'AAAA00', 'DDDDDD']) ================================================ FILE: src/scienceplots/styles/color/muted.mplstyle ================================================ # Muted color scheme # color-blind safe # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['CC6677', '332288', 'DDCC77', '117733', '88CCEE', '882255', '44AA99', '999933', 'AA4499', 'DDDDDD']) ================================================ FILE: src/scienceplots/styles/color/retro.mplstyle ================================================ # Retro color style # Set color cycle axes.prop_cycle : cycler('color', ['4165c0', 'e770a2', '5ac3be', '696969', 'f79a1e', 'ba7dcd']) ================================================ FILE: src/scienceplots/styles/color/std-colors.mplstyle ================================================ # Standard SciencePlots color cycle # Set color cycle: blue, green, yellow, red, violet, gray axes.prop_cycle : cycler('color', ['0C5DA5', '00B945', 'FF9500', 'FF2C00', '845B97', '474747', '9e9e9e']) ================================================ FILE: src/scienceplots/styles/color/vibrant.mplstyle ================================================ # Vibrant color scheme # color-blind safe # from Paul Tol's website: https://sronpersonalpages.nl/~pault/ # Set color cycle axes.prop_cycle : cycler('color', ['EE7733', '0077BB', '33BBEE', 'EE3377', 'CC3311', '009988', 'BBBBBB']) ================================================ FILE: src/scienceplots/styles/journals/ieee.mplstyle ================================================ # Matplotlib style for IEEE plots # This style should work for most two-column journals # Set color cycle # Set line style as well for black and white graphs axes.prop_cycle : (cycler('color', ['k', 'r', 'b', 'g']) + cycler('ls', ['-', '--', ':', '-.'])) # Set default figure size figure.figsize : 3.3, 2.5 figure.dpi : 600 # Font sizes font.size : 8 font.family : serif font.serif : Times ================================================ FILE: src/scienceplots/styles/journals/nature.mplstyle ================================================ # Matplotlib style for Nature journal figures. # In general, they advocate for all fonts to be panel labels to be sans serif # and all font sizes in a figure to be 7 pt and panel labels to be 8 pt bold. # Figure size figure.figsize : 3.3, 2.5 # max width is 3.5 for single column # Font sizes axes.labelsize: 7 xtick.labelsize: 7 ytick.labelsize: 7 legend.fontsize: 7 font.size: 7 # Font Family font.family: sans-serif font.sans-serif: DejaVu Sans, Arial, Helvetica, Lucida Grande, Verdana, Geneva, Lucid, Avant Garde, sans-serif mathtext.fontset : dejavusans # Set line widths axes.linewidth : 0.5 grid.linewidth : 0.5 lines.linewidth : 1. lines.markersize: 3 # Always save as 'tight' # savefig.bbox : tight # savefig.pad_inches : 0.01 # Use virtually all space when we specify figure dimensions # LaTeX packages text.latex.preamble : \usepackage{amsmath} \usepackage{amssymb} \usepackage{sfmath} ================================================ FILE: src/scienceplots/styles/languages/cjk-jp-font.mplstyle ================================================ # Add fonts for CJK characters (Japanese) # See FAQ in README for installation instructions font.serif : Noto Serif CJK JP font.family : serif ================================================ FILE: src/scienceplots/styles/languages/cjk-kr-font.mplstyle ================================================ # Add fonts for CJK characters (Korean) # See FAQ in README for installation instructions font.serif : Noto Serif CJK KR font.family : serif ================================================ FILE: src/scienceplots/styles/languages/cjk-sc-font.mplstyle ================================================ # Add fonts for CJK characters (simplified Chinese) # See FAQ in README for installation instructions font.serif : Noto Serif CJK SC font.family : serif ================================================ FILE: src/scienceplots/styles/languages/cjk-tc-font.mplstyle ================================================ # Add fonts for CJK characters (traditional Chinese) # See FAQ in README for installation instructions font.serif : Noto Serif CJK TC font.family : serif ================================================ FILE: src/scienceplots/styles/languages/russian-font.mplstyle ================================================ # Add Latex packages for Russian (cyrillic) fonts text.latex.preamble : \usepackage[russian]{babel} \usepackage[utf8]{inputenc} \usepackage[T2A]{fontenc} \usepackage{amsmath} \usepackage{amssymb} ================================================ FILE: src/scienceplots/styles/languages/turkish-font.mplstyle ================================================ # Add Latex packages for Turkish (Türkçe) fonts text.latex.preamble: \usepackage[turkish]{babel} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage{amsmath} \usepackage{amssymb} ================================================ FILE: src/scienceplots/styles/misc/grid.mplstyle ================================================ # Add grid lines and turn the legend frame on # Grid lines axes.grid : True axes.axisbelow : True grid.linestyle : -- grid.color : k grid.alpha : 0.5 grid.linewidth : 0.5 # Legend legend.frameon : True legend.framealpha : 1.0 legend.fancybox : True legend.numpoints : 1 ================================================ FILE: src/scienceplots/styles/misc/latex-sans.mplstyle ================================================ # Latex with sans-serif fonts mathtext.fontset : dejavusans # Use LaTeX for math formatting text.usetex : True # In general, we need to be careful with the preamble. A common font for # sans serif LaTeX is cmbright. However, it does not support bold fontweights # so we use sfmath instead. text.latex.preamble : \usepackage{amsmath} \usepackage{amssymb} \usepackage{sfmath} ================================================ FILE: src/scienceplots/styles/misc/no-latex.mplstyle ================================================ # Deactivate LaTeX # and use mathtext text.usetex : False # Set fonts to be LaTeX defaults font.serif : STIXGeneral font.family : serif axes.formatter.use_mathtext : True mathtext.fontset : cm ================================================ FILE: src/scienceplots/styles/misc/pgf.mplstyle ================================================ # Add LaTeX package to allow PGF plots text.latex.preamble : \usepackage{amsmath} \usepackage[T1]{fontenc} \usepackage{pgfplots} ================================================ FILE: src/scienceplots/styles/misc/sans.mplstyle ================================================ # Sans-serif font.family : sans-serif # Latex with sans-serif fonts mathtext.fontset : dejavusans # In general, we need to be careful with the preamble. A common font for # sans serif LaTeX is cmbright. However, it does not support bold fontweights # so we use sfmath instead. text.latex.preamble : \usepackage{amsmath} \usepackage{amssymb} \usepackage{sfmath} ================================================ FILE: src/scienceplots/styles/notebook.mplstyle ================================================ # Matplotlib style for Jupyter notebooks # Set default figure size figure.figsize : 8, 6 # Set x axis xtick.major.size : 6 xtick.major.width : 1 xtick.minor.size : 3 xtick.minor.width : 1 # Set y axis ytick.major.size : 6 ytick.major.width : 1 ytick.minor.size : 3 ytick.minor.width : 1 # Fontsizes xtick.labelsize : 16 ytick.labelsize : 16 legend.fontsize : 16 legend.title_fontsize : 16 axes.titlesize : 16 axes.labelsize : 16 # Set line widths axes.linewidth : 1 grid.linewidth : 1 lines.linewidth : 2. # Use sans-serif fonts font.family : sans-serif mathtext.fontset : dejavusans # Use LaTeX for math formatting text.usetex : False ================================================ FILE: src/scienceplots/styles/scatter.mplstyle ================================================ # Matplotlib style for scatter plots # Set markers (style, color, no lines) axes.prop_cycle : (cycler('marker', ['o', 's', '^', 'v', '<', '>', 'd']) + cycler('color', ['0C5DA5', '00B945', 'FF9500', 'FF2C00', '845B97', '474747', '9e9e9e']) + cycler('ls', [' ', ' ', ' ', ' ', ' ', ' ', ' '])) # Set marker size lines.markersize : 3 ================================================ FILE: src/scienceplots/styles/science.mplstyle ================================================ # Matplotlib style for scientific plotting # This is the base style for "SciencePlots" # see: https://github.com/garrettj403/SciencePlots # Set color cycle: blue, green, yellow, red, violet, gray axes.prop_cycle : cycler('color', ['0C5DA5', '00B945', 'FF9500', 'FF2C00', '845B97', '474747', '9e9e9e']) # Set default figure size figure.figsize : 3.5, 2.625 # Set x axis xtick.direction : in xtick.major.size : 3 xtick.major.width : 0.5 xtick.minor.size : 1.5 xtick.minor.width : 0.5 xtick.minor.visible : True xtick.top : True # Set y axis ytick.direction : in ytick.major.size : 3 ytick.major.width : 0.5 ytick.minor.size : 1.5 ytick.minor.width : 0.5 ytick.minor.visible : True ytick.right : True # Set line widths axes.linewidth : 0.5 grid.linewidth : 0.5 lines.linewidth : 1. # Remove legend frame legend.frameon : False # Always save as 'tight' savefig.bbox : tight savefig.pad_inches : 0.05 # Use serif fonts # font.serif : Times font.family : serif mathtext.fontset : dejavuserif # Use LaTeX for math formatting text.usetex : True text.latex.preamble : \usepackage{amsmath} \usepackage{amssymb} ================================================ FILE: src/scienceplots/styles_discovery.py ================================================ import os import matplotlib.pyplot as plt def read_styles_in_folders(root_path): """ Reads all stylesheets in the given path and its subfolders. Parameters ---------- root_path : str Path to the root folder containing the stylesheets and other subfolders with stylesheets. Returns ------- stylesheets : dict Dictionary of stylesheets in the form of {style_name: rcParams}. Should be compatible with matplotlib's plt.style.library dictionary. """ stylesheets = {} # plt.style.library is a dictionary for folder, _, _ in os.walk(root_path): new_stylesheets = plt.style.core.read_style_directory(folder) stylesheets.update(new_stylesheets) return stylesheets ================================================ FILE: src/scienceplots/tests/__init__.py ================================================ ================================================ FILE: src/scienceplots/tests/conftest.py ================================================ """ Configuration of SciencePlots tests """ import pytest import scienceplots import numpy as np import os from pathlib import Path STYLES_PATH = Path(scienceplots.__path__[0], "styles") def get_styles_in_dir(dir): """ Input: directory path Output: set of matplotlib styles filenames (without trailing '.mplstyle') """ styles_paths = Path(dir).glob("*.mplstyle") return set(fn.stem for fn in styles_paths) @pytest.fixture(scope="session") def styles_in_scienceplots_per_folder(): """ Output: dictionary of styles per folder in SciencePlots """ styles_per_folder = {} for folder, _, _ in os.walk(STYLES_PATH): # 1st _ : subdirs, 2nd _ : files folder = Path(folder) styles_per_folder[folder.name] = get_styles_in_dir(folder) return styles_per_folder @pytest.fixture(scope="session") def xy_example_values(): """ Output: "x" 1D values, "y" 2D values, and 1D "p" values for the example plot """ def model(x, p): # from examples/plot-examples.py return x ** (2 * p + 1) / (1 + x ** (2 * p)) x = np.linspace(0.75, 1.25, 201) p = [10, 15, 20, 30, 50, 100] res = np.fromiter(map(lambda p: model(x, p), p), dtype=np.dtype((float, len(x)))) return x, res, p ================================================ FILE: src/scienceplots/tests/test_scienceplots.py ================================================ """Test suite of SciencePlots """ import matplotlib.pyplot as plt def test_matplotlib_required_api_existence(): """Check if all functions and attributes used by scienceplots are available in matplotlib. """ assert hasattr(plt.style, "core") assert hasattr(plt.style.core, "read_style_directory") assert hasattr(plt.style.core, "update_nested_dict") assert hasattr(plt.style, "available") assert hasattr(plt.style, "library") def test_styles_existence(styles_in_scienceplots_per_folder): """Check all styles are available in matplotlib.""" for folder, styles in styles_in_scienceplots_per_folder.items(): assert len(styles) > 0, f"No styles found in {folder}." for style in styles: assert ( # both in list of names and the library they are retrieved from hello style in plt.style.available and style in plt.style.library ), f"'{style}' not in available styles. Style in folder {folder}." def test_usage_of_each_style( xy_example_values, styles_in_scienceplots_per_folder, tmp_path, ): """Tests if the styles are correctly formatted and can be applied to a plot.""" pparam = {"xlabel": "Voltage (mV)", "ylabel": r"Current ($\mu$A)"} x, ys, p = xy_example_values for folder, styles in styles_in_scienceplots_per_folder.items(): for style in styles: output_file = tmp_path / f"test_{folder}_{style}.png" with plt.style.context(style): fig, ax = plt.subplots() for y in ys: ax.plot(x, y) ax.legend(p, title="Order") ax.set(**pparam) ax.autoscale(tight=True) fig.savefig(output_file) plt.close(fig)