wedme-plots


Namewedme-plots JSON
Version 2.0.3 PyPI version JSON
download
home_pageNone
SummaryWe Don't Make Embarrassing Plots. Matplotlib styles for papers, posters, presentations and theses.
upload_time2024-04-19 10:59:36
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License Copyright (c) 2018 Real Python 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.
keywords matplotlib
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 👗 wedme-plots: We Don't Make Embarrassing Plots

Matplotlib styles for papers, posters, presentations and theses. Tailored for academic use.

## Too long; didn't read
1. Pick a style from `paper`, `slide`, `a0`, `thesis`.
2. Decide the final size of the figure on the chosen medium. 
For example, the column width (`cw`) and default height (`dh`) for the `paper` style.
3. Import `wedme`
4. Before using matplotlib, apply the style using `wedme.apply.[style]_[width]_[height]()`. In the above example, `wedme.apply.paper_cw_dh()`.


## Installation
Install from [PyPI](https://pypi.org/project/wedme-plots/) using PIP:
```
pip install wedme-plots
```

For Anaconda users:
- Open an Anaconda Prompt
- Optional: if you use an environment other than `base`, open it using `conda activate [my environment]`
- Install pip using `conda install pip`
- Install wedme-plots using `pip install wedme-plots`

## Styling
Wedme offers multiple styles:
- `paper`: compatible with most journals (Nature, Science, Elsevier). 
- `slide`: compatible with a (16:9) Microsoft Powerpoint presentation. 
- `a0`: A0 poster.
- `thesis`: (work-in-progress) similar to `paper` but for the B5 page format.

## Usage
There are two ways of applying a wedme style. 

### 1. Global styling and sizing

Import the `wedme` module and apply the desired style, e.g. `wedme.apply.paper()`. 
This applies the specified style and its default size to every subsequent figure.

Example:
```python
import wedme

# These commands apply a style to subsequent Matplotlib figures.

# Pick one:
wedme.apply.paper()  # For Elsevier-compatible paper styles
wedme.apply.slide()  # For a 16:9 Powerpoint slide
wedme.apply.a0()     # For A0 posters
wedme.apply.thesis() # For B5-paper thesis

# Optionally, change the default size:
wedme.apply.slide_tw_hh()

# Proceed with plotting as usual
import matplotlib.pyplot as plt

plt.figure()
plt.plot([1, 2, 3, 4])
plt.show()
```

### 2. Local styling and sizing

Alternatively, one can open figures in a specified style and size using the `wedme` drop-in replacements for `plt.figure()` and `plt.subplots()` as follows:

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

# Open a figure in the `a0` style, 
# with a size corresponding to half-width and half-height
wedme.figure.a0_hw_hh()
plt.plot([1, 2, 3, 4])

# Open a figure with two subplots in the `slide` style,
# with the figure size corresponding to half-width and half-height
fig, (ax1, ax2) = wedme.subplots.slide_hw_hh(1, 2)

ax1.plot([1, 2, 3, 4])
ax2.plot([1, 2, 3, 4])
```

Any arguments passed to `wedme.figure.[style]()` and `wedme.subplots.[style]()` are passed on to the equivalent matplotlib functions.

## Sizing
Matching the matplotlib figure size to the final display size of the figure is critically important: scaling to a different height will change font sizes and line widths.

We include the following breakpoints, with respect to the available width and height (`H`) of the chosen medium:
| Breakpoint | Ratio |
| -- | -- |
| `F` | 100% _("full")_ |
| `TT` | 2/3 _("two-thirds")_ |
| `H` | 1/2 _("half")_ |
| `FT` | 5/12 _("five-twelfth")_ |
| `T` | 1/3 _("third")_ |
| `Q` | 1/4 _("quarter")_ |
| `R` | 1/5 |
| `S` | 1/6 |

To specify the size using a breakpoint, append `W` (width) or `H` (height). For example, `wedme.figure.a0_hw_hh()` specifies the `a0` style, with a size of half the A0 width and height.

In addition to the breakpoints, some styles include custom sizes:
- `paper`: `CW` (column width) for two-column papers. `GH` is the height that corresponds to the golden-ratio of `CW`.
- `thesis`: `LFW` and `LFH` for the landscape full-width and full-height.
The default width and height `DW` and `DH` correspond to `CW` and `GH` of the `paper` style

</br>

When no size is specified, the following defaults sizes are used:
- `paper`: `(wedme.PAPER_CW, wedme.paper_GH)`
- `slide`: `(wedme.SLIDE_TW, wedme.slide_HH)`
- `a0`:  `(wedme.A0_TW, ...)`
- `thesis`: `(wedme.THESIS_DW, wedme.paper_DH)`


## Powerpoint
Powerpoint automatically resizes artwork to a size that is different from the export size. To undo this:
- Insert the figure in Powerpoint.
- Picture Format > Reset Picture > Reset Picture & Size.

## Fonts
Sans-serif fonts are the standards for figures because they remain readable even when small or pixelated. Helvetica or Arial fonts are preferred by Nature, Science and Elsevier. 

We try to find Helvetica, Arial, Verdana, Inter, Nimbus Sans on your system, in that order. The first font found will be applied to the figures.

## Exporting
`wedme` sets the `pdf.fonttype` parameter to `42` as recommended by Nature. This ensures that the text is editable even after exporting a pdf. `wedme` also changes the parameters `figure.autolayout` and `savefig.bbox` such that the specified sizes are respected.

For saving figures, consider using [pypdfplot](https://github.com/dcmvdbekerom/pypdfplot) to maintain the ability to later change how data is displayed. Of course, we don't make embarassing plots to begin with.

## Examples
<img src="https://github.com/mruijzendaal/wedme-plots/blob/main/img/calibration_curve_rot.png?raw=true" width="512">

## Utilities
Other than style sheets, wedme also includes utilities for commonly used operations.
- Creating animated GIF images from multiple plots. See `wedme.gif`
- Creating a legend only for unique entries. See `wedme.util.unique_legend()`
- Specifying the colorbar label easily. See `wedme.util.colorbar()`
- Specifying the minimum and maximum of the colorbar as a function of percentiles of the shown field. See `wedme.util.imshow()`
- Making plot colors dependent on some variable. See `weme.util.get_colormap_norm()`

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "wedme-plots",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "matplotlib",
    "author": null,
    "author_email": "Martijn Ruijzendaal <martijn.ruijzendaal@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/32/60/d3f6efdac2cba652d440eed70ad04338875a2b98c83297c2f78cb853a922/wedme_plots-2.0.3.tar.gz",
    "platform": null,
    "description": "# \ud83d\udc57 wedme-plots: We Don't Make Embarrassing Plots\n\nMatplotlib styles for papers, posters, presentations and theses. Tailored for academic use.\n\n## Too long; didn't read\n1. Pick a style from `paper`, `slide`, `a0`, `thesis`.\n2. Decide the final size of the figure on the chosen medium. \nFor example, the column width (`cw`) and default height (`dh`) for the `paper` style.\n3. Import `wedme`\n4. Before using matplotlib, apply the style using `wedme.apply.[style]_[width]_[height]()`. In the above example, `wedme.apply.paper_cw_dh()`.\n\n\n## Installation\nInstall from [PyPI](https://pypi.org/project/wedme-plots/) using PIP:\n```\npip install wedme-plots\n```\n\nFor Anaconda users:\n- Open an Anaconda Prompt\n- Optional: if you use an environment other than `base`, open it using `conda activate [my environment]`\n- Install pip using `conda install pip`\n- Install wedme-plots using `pip install wedme-plots`\n\n## Styling\nWedme offers multiple styles:\n- `paper`: compatible with most journals (Nature, Science, Elsevier). \n- `slide`: compatible with a (16:9) Microsoft Powerpoint presentation. \n- `a0`: A0 poster.\n- `thesis`: (work-in-progress) similar to `paper` but for the B5 page format.\n\n## Usage\nThere are two ways of applying a wedme style. \n\n### 1. Global styling and sizing\n\nImport the `wedme` module and apply the desired style, e.g. `wedme.apply.paper()`. \nThis applies the specified style and its default size to every subsequent figure.\n\nExample:\n```python\nimport wedme\n\n# These commands apply a style to subsequent Matplotlib figures.\n\n# Pick one:\nwedme.apply.paper()  # For Elsevier-compatible paper styles\nwedme.apply.slide()  # For a 16:9 Powerpoint slide\nwedme.apply.a0()     # For A0 posters\nwedme.apply.thesis() # For B5-paper thesis\n\n# Optionally, change the default size:\nwedme.apply.slide_tw_hh()\n\n# Proceed with plotting as usual\nimport matplotlib.pyplot as plt\n\nplt.figure()\nplt.plot([1, 2, 3, 4])\nplt.show()\n```\n\n### 2. Local styling and sizing\n\nAlternatively, one can open figures in a specified style and size using the `wedme` drop-in replacements for `plt.figure()` and `plt.subplots()` as follows:\n\n```python\nimport wedme\nimport matplotlib.pyplot as plt\n\n# Open a figure in the `a0` style, \n# with a size corresponding to half-width and half-height\nwedme.figure.a0_hw_hh()\nplt.plot([1, 2, 3, 4])\n\n# Open a figure with two subplots in the `slide` style,\n# with the figure size corresponding to half-width and half-height\nfig, (ax1, ax2) = wedme.subplots.slide_hw_hh(1, 2)\n\nax1.plot([1, 2, 3, 4])\nax2.plot([1, 2, 3, 4])\n```\n\nAny arguments passed to `wedme.figure.[style]()` and `wedme.subplots.[style]()` are passed on to the equivalent matplotlib functions.\n\n## Sizing\nMatching the matplotlib figure size to the final display size of the figure is critically important: scaling to a different height will change font sizes and line widths.\n\nWe include the following breakpoints, with respect to the available width and height (`H`) of the chosen medium:\n| Breakpoint | Ratio |\n| -- | -- |\n| `F` | 100% _(\"full\")_ |\n| `TT` | 2/3 _(\"two-thirds\")_ |\n| `H` | 1/2 _(\"half\")_ |\n| `FT` | 5/12 _(\"five-twelfth\")_ |\n| `T` | 1/3 _(\"third\")_ |\n| `Q` | 1/4 _(\"quarter\")_ |\n| `R` | 1/5 |\n| `S` | 1/6 |\n\nTo specify the size using a breakpoint, append `W` (width) or `H` (height). For example, `wedme.figure.a0_hw_hh()` specifies the `a0` style, with a size of half the A0 width and height.\n\nIn addition to the breakpoints, some styles include custom sizes:\n- `paper`: `CW` (column width) for two-column papers. `GH` is the height that corresponds to the golden-ratio of `CW`.\n- `thesis`: `LFW` and `LFH` for the landscape full-width and full-height.\nThe default width and height `DW` and `DH` correspond to `CW` and `GH` of the `paper` style\n\n</br>\n\nWhen no size is specified, the following defaults sizes are used:\n- `paper`: `(wedme.PAPER_CW, wedme.paper_GH)`\n- `slide`: `(wedme.SLIDE_TW, wedme.slide_HH)`\n- `a0`:  `(wedme.A0_TW, ...)`\n- `thesis`: `(wedme.THESIS_DW, wedme.paper_DH)`\n\n\n## Powerpoint\nPowerpoint automatically resizes artwork to a size that is different from the export size. To undo this:\n- Insert the figure in Powerpoint.\n- Picture Format > Reset Picture > Reset Picture & Size.\n\n## Fonts\nSans-serif fonts are the standards for figures because they remain readable even when small or pixelated. Helvetica or Arial fonts are preferred by Nature, Science and Elsevier. \n\nWe try to find Helvetica, Arial, Verdana, Inter, Nimbus Sans on your system, in that order. The first font found will be applied to the figures.\n\n## Exporting\n`wedme` sets the `pdf.fonttype` parameter to `42` as recommended by Nature. This ensures that the text is editable even after exporting a pdf. `wedme` also changes the parameters `figure.autolayout` and `savefig.bbox` such that the specified sizes are respected.\n\nFor saving figures, consider using [pypdfplot](https://github.com/dcmvdbekerom/pypdfplot) to maintain the ability to later change how data is displayed. Of course, we don't make embarassing plots to begin with.\n\n## Examples\n<img src=\"https://github.com/mruijzendaal/wedme-plots/blob/main/img/calibration_curve_rot.png?raw=true\" width=\"512\">\n\n## Utilities\nOther than style sheets, wedme also includes utilities for commonly used operations.\n- Creating animated GIF images from multiple plots. See `wedme.gif`\n- Creating a legend only for unique entries. See `wedme.util.unique_legend()`\n- Specifying the colorbar label easily. See `wedme.util.colorbar()`\n- Specifying the minimum and maximum of the colorbar as a function of percentiles of the shown field. See `wedme.util.imshow()`\n- Making plot colors dependent on some variable. See `weme.util.get_colormap_norm()`\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2018 Real Python  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. ",
    "summary": "We Don't Make Embarrassing Plots. Matplotlib styles for papers, posters, presentations and theses.",
    "version": "2.0.3",
    "project_urls": {
        "documentation": "https://github.com/mruijzendaal/wedme-plots",
        "repository": "https://github.com/mruijzendaal/wedme-plots"
    },
    "split_keywords": [
        "matplotlib"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3260d3f6efdac2cba652d440eed70ad04338875a2b98c83297c2f78cb853a922",
                "md5": "1e1a01752b9793b6c5c24e8db5487fe2",
                "sha256": "586f736cec921d5a3b2a6b555da749616a647bc3514a85613552a4fe70a74332"
            },
            "downloads": -1,
            "filename": "wedme_plots-2.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "1e1a01752b9793b6c5c24e8db5487fe2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 14870,
            "upload_time": "2024-04-19T10:59:36",
            "upload_time_iso_8601": "2024-04-19T10:59:36.597831Z",
            "url": "https://files.pythonhosted.org/packages/32/60/d3f6efdac2cba652d440eed70ad04338875a2b98c83297c2f78cb853a922/wedme_plots-2.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-19 10:59:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mruijzendaal",
    "github_project": "wedme-plots",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "wedme-plots"
}
        
Elapsed time: 0.23817s