LovelyPlots


NameLovelyPlots JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/killiansheriff/LovelyPlots
SummaryFormat Matplotlib Plots for thesis, scientific papers and reports.
upload_time2024-03-05 05:37:40
maintainer
docs_urlNone
authorKillian Sheriff
requires_python
licenseMIT
keywords matplotlib-style-sheets matplotlib-figures scientific-papers phd thesis-template matplotlib-styles adobe illustrator latex latex-figures
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LovelyPlots
![PyPI Version](https://img.shields.io/pypi/v/LovelyPlots.svg) ![PyPI Downloads](https://static.pepy.tech/badge/LovelyPlots) [![doi](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.6903937-blue)](
http://doi.org/10.5281/zenodo.6903937) ![tests](https://github.com/killiansheriff/WarrenCowleyParameters/actions/workflows/python-tests.yml/badge.svg)

> **Warning**
> : As of version 1.0.0, you need to add ``import lovelyplots`` before setting the style (``plt.style.use('ipynb')``).

LovelyPlots is a repository containing ``matplotlib`` style sheets to nicely format figures for scientific papers, thesis and presentations while keeping them fully editable in ``Adobe Illustrator``. Additonaly, ``.svg`` exports options allows figures to automatically adapt their font to your document's font. For example, ``.svg`` figures imported in a ``.tex`` file will automatically be generated with the text font used in your ``.tex`` file.

<p align="center" width="50%">
    <img width="70%" src="figs/plots/ipynb+use_mathtext.svg">
</p>

# Installation

```bash
# to install latest PyPI release
pip install LovelyPlots

# to install latest GitHub commit
pip install --upgrade git+https://github.com/killiansheriff/LovelyPlots.git
```

The pip installation will move all of the ``matplotlib`` style files ``*.mplstyle`` into the appropriate ``matplotlib`` directory.

# Usage

LovelyPlots main style is called ``ipynb``. To use it, add the following lines to the begining of your python scripts:

```python
import lovelyplots
import matplotlib.pyplot as plt
plt.style.use('ipynb')
```

Styles can be combined:

```python
import lovelyplots
import matplotlib.pyplot as plt
plt.style.use(['ipynb','colorsblind34'])
```

In the above case, the ``ipynb`` default color cycle will be overwritten by a 34 colors colorblind safe color cycle called ``colorsblind34``.

If you only wish to apply a style on a specific plot, this can be achieved using:

```python
import lovelyplots
import matplotlib.pyplot as plt

with plt.style.context('ipynb'):
  fig, ax = plt.subplots()
  ax.plot(x, y)
```

# Examples

A few styles are presented here, please see [Styles](#Styles) for a list of all implemented styles. The script used to generate these plots can be found [here](examples/plot.py).

:warning: If you use the ``use_mathtext`` style, ``Adobe Illustrator`` might fail to nicely detect text objects. Please see [here](#Tips-and-Tricks) for work arounds.


The ``['ipynb', 'use_mathtext']`` style:

![](figs/plots/ipynb%2Buse_mathtext.svg)

The ``['ipynb', 'use_mathtext','colors10-markers']`` style:

![](figs/plots/ipynb%2Buse_mathtext+colors10-markers.svg)

The ``['ipynb', 'use_mathtext','colors5-light']`` style:

![](figs/plots/ipynb%2Buse_mathtext+colors5-light.svg)

The ``['ipynb', 'use_mathtext', 'colors10-ls']`` style:

![](figs/plots/ipynb%2Buse_mathtext+colors10-ls.svg)

The ``['ipynb']`` style:

![](figs/plots/ipynb.svg)

The ``['paper', 'use_mathtext']`` style:

![](figs/plots/paper+use_mathtext.svg)

# Styles

LovelyPlots main style is called ``ipynb``. The latter by default sets the figure size to ``(4.5, 3.46) inches``, uses the default ``matplotlib`` font, activate scientific notation and makes sure your ``matplotlib`` exports will be editable in ``Adobe Illustrator``. Its default color cycle was set to ``colors10``.

## Color cycles

A multitude of color cycles were implemented:

``colors5-light``

![](figs/colors/colors5-light.png)

``colors5``

![](figs/colors/color5.png)

``colors10``

![](figs/colors/color10.png)

``colorsblind10``

![](figs/colors/colorsblind10.png)

``colorsblind34``

Can be seen [here](figs/colors/colorsblind34.png).


## Lines styles, markers and combinations styles

Line styles, markers styles and combinations can be set using the following styles: `ls5`, `marker7`, `colors10-ls`, `colors10-markers`.

## Color maps
Default ``matplotlib`` colormaps were implemented and can be used by adding the following styles: ``cmap-viridis``, ``cmap-inferno``, ``cmap-cividis``, ``cmap-magma``, ``cmap-plasma``.

## Utils

Specific ``matplotlibrc`` parameters can be turned ``on/off`` using the following utilities styles: ``svg_no_fonttype``, ``use_mathtex``, ``use_tex``.

## Fonts

By default the ``ipynb`` style uses the default ``matplotlib`` font. However, one can set its favorite font from a TIFF file:

```python
import lovelyplots as lp
import matplotlib.pyplot as plt

plt.style.use('ipynb')
lp.utils.set_font('my_font.tiff')
```




# Tips and Tricks

## Adobe Illustrator

Unfortunately, ``mathtext`` (and thus nicely formated scientific notation) will mess up ``Adobe illustrator`` ability to detect text objects, and is thus not activated by default. If you wish to use it, please add the style ``use_mathtext``.

## Latex and SVG files
By default, the ``ipynb`` style sets ``svg.fonttype: none``. This allows for plots saved as ``.svg`` not to carry font information. Consequently, when opened in another environement, the plot will be generated with the default system font.

For example, this allows ``.svg`` plots imported inside a ``Latex`` file to directly be generated with the proper document font, without you having to manually edit the fonts to match your document's font. Additonally, you can open the ``.svg`` file as  text file, find the ugly ``1e10`` scientific notation and replace it with ``$10^10$`` so that it is nicely formated when included in your ``.tex`` file.

An example of how to show an svg in a ``.tex`` file:

```tex
\usepackage{svg}

\begin{figure}[htbp]
  \centering
  \includesvg{myfig.svg}
\end{figure}
```
## Retina displays

For those using ``IPython`` notebooks, you can set retina display support by adding the following lines to the begining on your python script:


```python
import lovelyplots as lp
lp.utils.set_retina()
```
## Useth in Google Colab
To use on Google Colab, you will need to run the following code:
```python
!pip install lovelyplots
import lovelyplots
plt.style.reload_library()
plt.style.use('ipynb')
```

# Acknowledgements

This reprository was inspired by [SciencePlots](https://github.com/garrettj403/SciencePlots), but adds different styles and crucial functionalities for useth in ``.tex`` files and ``Adobe Illustrator``.


# Citing 

If you use LovelyPlots, please consider citing: 

    @software{killian_sheriff_2022_6916993,
      author       = {Killian Sheriff},
      title        = {{LovelyPlots, a collection of matplotlib 
                       stylesheets for scientific figures}},
      month        = jul,
      year         = 2022,
      publisher    = {Zenodo},
      version      = {v0.0.26\_LovelyPlots},
      doi          = {10.5281/zenodo.6916993},
      url          = {https://doi.org/10.5281/zenodo.6916993}
    }

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/killiansheriff/LovelyPlots",
    "name": "LovelyPlots",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "matplotlib-style-sheets,matplotlib-figures,scientific-papers,PhD,thesis-template,matplotlib-styles,Adobe Illustrator,Latex,latex-figures",
    "author": "Killian Sheriff",
    "author_email": "killian.sheriff@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c8/08/a76b41aa5bacf6c0f813a522eb9d6b8d285226783751775ad4b2fa9303a8/LovelyPlots-1.0.0.tar.gz",
    "platform": null,
    "description": "# LovelyPlots\n![PyPI Version](https://img.shields.io/pypi/v/LovelyPlots.svg) ![PyPI Downloads](https://static.pepy.tech/badge/LovelyPlots) [![doi](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.6903937-blue)](\nhttp://doi.org/10.5281/zenodo.6903937) ![tests](https://github.com/killiansheriff/WarrenCowleyParameters/actions/workflows/python-tests.yml/badge.svg)\n\n> **Warning**\n> : As of version 1.0.0, you need to add ``import lovelyplots`` before setting the style (``plt.style.use('ipynb')``).\n\nLovelyPlots is a repository containing ``matplotlib`` style sheets to nicely format figures for scientific papers, thesis and presentations while keeping them fully editable in ``Adobe Illustrator``. Additonaly, ``.svg`` exports options allows figures to automatically adapt their font to your document's font. For example, ``.svg`` figures imported in a ``.tex`` file will automatically be generated with the text font used in your ``.tex`` file.\n\n<p align=\"center\" width=\"50%\">\n    <img width=\"70%\" src=\"figs/plots/ipynb+use_mathtext.svg\">\n</p>\n\n# Installation\n\n```bash\n# to install latest PyPI release\npip install LovelyPlots\n\n# to install latest GitHub commit\npip install --upgrade git+https://github.com/killiansheriff/LovelyPlots.git\n```\n\nThe pip installation will move all of the ``matplotlib`` style files ``*.mplstyle`` into the appropriate ``matplotlib`` directory.\n\n# Usage\n\nLovelyPlots main style is called ``ipynb``. To use it, add the following lines to the begining of your python scripts:\n\n```python\nimport lovelyplots\nimport matplotlib.pyplot as plt\nplt.style.use('ipynb')\n```\n\nStyles can be combined:\n\n```python\nimport lovelyplots\nimport matplotlib.pyplot as plt\nplt.style.use(['ipynb','colorsblind34'])\n```\n\nIn the above case, the ``ipynb`` default color cycle will be overwritten by a 34 colors colorblind safe color cycle called ``colorsblind34``.\n\nIf you only wish to apply a style on a specific plot, this can be achieved using:\n\n```python\nimport lovelyplots\nimport matplotlib.pyplot as plt\n\nwith plt.style.context('ipynb'):\n  fig, ax = plt.subplots()\n  ax.plot(x, y)\n```\n\n# Examples\n\nA few styles are presented here, please see [Styles](#Styles) for a list of all implemented styles. The script used to generate these plots can be found [here](examples/plot.py).\n\n:warning: If you use the ``use_mathtext`` style, ``Adobe Illustrator`` might fail to nicely detect text objects. Please see [here](#Tips-and-Tricks) for work arounds.\n\n\nThe ``['ipynb', 'use_mathtext']`` style:\n\n![](figs/plots/ipynb%2Buse_mathtext.svg)\n\nThe ``['ipynb', 'use_mathtext','colors10-markers']`` style:\n\n![](figs/plots/ipynb%2Buse_mathtext+colors10-markers.svg)\n\nThe ``['ipynb', 'use_mathtext','colors5-light']`` style:\n\n![](figs/plots/ipynb%2Buse_mathtext+colors5-light.svg)\n\nThe ``['ipynb', 'use_mathtext', 'colors10-ls']`` style:\n\n![](figs/plots/ipynb%2Buse_mathtext+colors10-ls.svg)\n\nThe ``['ipynb']`` style:\n\n![](figs/plots/ipynb.svg)\n\nThe ``['paper', 'use_mathtext']`` style:\n\n![](figs/plots/paper+use_mathtext.svg)\n\n# Styles\n\nLovelyPlots main style is called ``ipynb``. The latter by default sets the figure size to ``(4.5, 3.46) inches``, uses the default ``matplotlib`` font, activate scientific notation and makes sure your ``matplotlib`` exports will be editable in ``Adobe Illustrator``. Its default color cycle was set to ``colors10``.\n\n## Color cycles\n\nA multitude of color cycles were implemented:\n\n``colors5-light``\n\n![](figs/colors/colors5-light.png)\n\n``colors5``\n\n![](figs/colors/color5.png)\n\n``colors10``\n\n![](figs/colors/color10.png)\n\n``colorsblind10``\n\n![](figs/colors/colorsblind10.png)\n\n``colorsblind34``\n\nCan be seen [here](figs/colors/colorsblind34.png).\n\n\n## Lines styles, markers and combinations styles\n\nLine styles, markers styles and combinations can be set using the following styles: `ls5`, `marker7`, `colors10-ls`, `colors10-markers`.\n\n## Color maps\nDefault ``matplotlib`` colormaps were implemented and can be used by adding the following styles: ``cmap-viridis``, ``cmap-inferno``, ``cmap-cividis``, ``cmap-magma``, ``cmap-plasma``.\n\n## Utils\n\nSpecific ``matplotlibrc`` parameters can be turned ``on/off`` using the following utilities styles: ``svg_no_fonttype``, ``use_mathtex``, ``use_tex``.\n\n## Fonts\n\nBy default the ``ipynb`` style uses the default ``matplotlib`` font. However, one can set its favorite font from a TIFF file:\n\n```python\nimport lovelyplots as lp\nimport matplotlib.pyplot as plt\n\nplt.style.use('ipynb')\nlp.utils.set_font('my_font.tiff')\n```\n\n\n\n\n# Tips and Tricks\n\n## Adobe Illustrator\n\nUnfortunately, ``mathtext`` (and thus nicely formated scientific notation) will mess up ``Adobe illustrator`` ability to detect text objects, and is thus not activated by default. If you wish to use it, please add the style ``use_mathtext``.\n\n## Latex and SVG files\nBy default, the ``ipynb`` style sets ``svg.fonttype: none``. This allows for plots saved as ``.svg`` not to carry font information. Consequently, when opened in another environement, the plot will be generated with the default system font.\n\nFor example, this allows ``.svg`` plots imported inside a ``Latex`` file to directly be generated with the proper document font, without you having to manually edit the fonts to match your document's font. Additonally, you can open the ``.svg`` file as  text file, find the ugly ``1e10`` scientific notation and replace it with ``$10^10$`` so that it is nicely formated when included in your ``.tex`` file.\n\nAn example of how to show an svg in a ``.tex`` file:\n\n```tex\n\\usepackage{svg}\n\n\\begin{figure}[htbp]\n  \\centering\n  \\includesvg{myfig.svg}\n\\end{figure}\n```\n## Retina displays\n\nFor those using ``IPython`` notebooks, you can set retina display support by adding the following lines to the begining on your python script:\n\n\n```python\nimport lovelyplots as lp\nlp.utils.set_retina()\n```\n## Useth in Google Colab\nTo use on Google Colab, you will need to run the following code:\n```python\n!pip install lovelyplots\nimport lovelyplots\nplt.style.reload_library()\nplt.style.use('ipynb')\n```\n\n# Acknowledgements\n\nThis reprository was inspired by [SciencePlots](https://github.com/garrettj403/SciencePlots), but adds different styles and crucial functionalities for useth in ``.tex`` files and ``Adobe Illustrator``.\n\n\n# Citing \n\nIf you use LovelyPlots, please consider citing: \n\n    @software{killian_sheriff_2022_6916993,\n      author       = {Killian Sheriff},\n      title        = {{LovelyPlots, a collection of matplotlib \n                       stylesheets for scientific figures}},\n      month        = jul,\n      year         = 2022,\n      publisher    = {Zenodo},\n      version      = {v0.0.26\\_LovelyPlots},\n      doi          = {10.5281/zenodo.6916993},\n      url          = {https://doi.org/10.5281/zenodo.6916993}\n    }\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Format Matplotlib Plots for thesis, scientific papers and reports.",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/killiansheriff/LovelyPlots"
    },
    "split_keywords": [
        "matplotlib-style-sheets",
        "matplotlib-figures",
        "scientific-papers",
        "phd",
        "thesis-template",
        "matplotlib-styles",
        "adobe illustrator",
        "latex",
        "latex-figures"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8c113798e4f5a8f1a03910e58888fb6d129e1449ef9c2ab6c22b2a0013f02d25",
                "md5": "d616a9901406a094ecffa6a78937cb66",
                "sha256": "7b3c2fbe1eaa26c8f1f81d7ce1c5e99d5ee73048e1fc17f7ffdd0939e0b3b3a2"
            },
            "downloads": -1,
            "filename": "LovelyPlots-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d616a9901406a094ecffa6a78937cb66",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 12518,
            "upload_time": "2024-03-05T05:37:38",
            "upload_time_iso_8601": "2024-03-05T05:37:38.760002Z",
            "url": "https://files.pythonhosted.org/packages/8c/11/3798e4f5a8f1a03910e58888fb6d129e1449ef9c2ab6c22b2a0013f02d25/LovelyPlots-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c808a76b41aa5bacf6c0f813a522eb9d6b8d285226783751775ad4b2fa9303a8",
                "md5": "a908328282c3848620a6a7f48420ab6a",
                "sha256": "bd2d8286d4186620e301c5524d260f8ef77e36f4ea70b942361ed81a2347cdf1"
            },
            "downloads": -1,
            "filename": "LovelyPlots-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a908328282c3848620a6a7f48420ab6a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8596,
            "upload_time": "2024-03-05T05:37:40",
            "upload_time_iso_8601": "2024-03-05T05:37:40.475372Z",
            "url": "https://files.pythonhosted.org/packages/c8/08/a76b41aa5bacf6c0f813a522eb9d6b8d285226783751775ad4b2fa9303a8/LovelyPlots-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-05 05:37:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "killiansheriff",
    "github_project": "LovelyPlots",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "lovelyplots"
}
        
Elapsed time: 0.21181s