{ "info": { "author": "Tobias Schruff", "author_email": "tobias.schruff@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "# mpls\n`mpls` is a small lightweight pure Python package that manages the access to a repository of matplotlib styles and makes\nit easy to use and switch between different styles. To specify the style of the figures in your Python script or\nnotebook just write\n```python\nimport matplotlib.pyplot as plt\nimport mpls\n\nmpls.use('gplot', context='a5')\n...\n```\nand depending on the configuration of your style library you have access to styles from a remote (public) library or the\npersonal style library on your computer.\n\n## About\nI work as a scientist and one of the major tasks of my daily work is to create reports, publications, and presentations.\nPersonally, I prefer figures over text, but, I know, sometimes it is inevitable to add some paragraphs of text between the\nfigures. However, being faced with the situation to produce many figures for _multiple contexts_ (report, journal, slides,\netc.) with _consistent_ _style_ and _colors_, I started to use matplotlib stylesheets to be able to store and load my\ncustom settings. To be honest, I didn't enjoy working with stylesheet files very much due to a couple of reasons (e.g. ).\n\nSimilar to [seaborn][1], `mpls` styles are organized in three types: **context**, **style**, and\n**palette**.\n\nThe **context** defines size relevant properties such as figure size, size of marker\npoints, etc.\nMore details on which `rcParams` belong to the **context** can be found [here](doc/context.md).\n\nThe **style** defines the general style properties such as basic figure _colors_ and _fonts_.\nMore details on which `rcParams` belong to the **style** can be found [here](doc/style.md).\n\nThe **palette** defines the color properties such as the colormap of images or the\ncolor of markers and lines.\nMore details on which `rcParams` belong to the **palette** can be found [here](doc/palette.md).\n\n### Style files\nTechnically, each of the three style types represents a subset of the `rcParams` dict in [matplotlib][2]. The\nparameters dict instances are stored in a in so-called _style files_. These style files are regular _json_ files, with\nthe exception that it is allowed to have C-style comments in the file. A small example of a valid **context** style file\nis\n```javascript\n{\n // this is a line comment\n \"figure.figsize\": [3, 4],\n\n /* this is a multi-\n line comment */\n \"font.size\": 10\n}\n```\nFor more examples of style files have a look at the files in the [stylelib](stylelib/) of this repository.\n\n_Note_: In the current version, parameters defined in style files are not restricted to a certain subset of `rcParams`.\nGenerally, you can define any parameter in any style file! This is useful in some cases. However, this may change in\nthe future and in order to make working with style files easy and intuitive, please restrict yourself to the\nparameters specified in the respective style file documentation.\n\n## Installation\nThe easiest way to install `mpls` is to use `pip`, i.e.\n```\npip install mpls\n```\n\nHowever, if you want to work with the most recent version of `mpls`, you can just clone the repository and run\nsetuptools in the source folder like\n```\npython setup.py install\n```\n\n## Requirements\nThere is only one (quite obvious) requirement\n- `matplotlib`\n\n## Examples\nAn example where the plotting context is modified temporarily.\n```python\nimport matplotlib.pyplot as plt\nimport mpls\n\nmpls.use(context='a4-gr', style='thesis', palette='grayscale')\n\n# create some plot\n...\n\nwith mpls.temp(context='a4-gr-ls'):\n # temporarily switch to A4 landscape format\n ...\n\n# continue with regular A4 format\n...\n```\n\nAn example of mixing `matplotlib` and `mpls` styles\n```python\nimport matplotlib.pyplot as plt\nimport mpls\n\n# mix a matplotlib style with an mpls palette\nmpls.use('dark_background', palette='grayscale')\n\n# create some plots\n...\n```\n\n## Contributing\nContributions to the `mpls` code or the stylelib in this repository are very welcome. Just issue a pull request at the\ngithub page.\n\n## Using a custom style library\nAs default `mpls` fetches styles from the stylelib folder in this repository. But it is also possible to fetch files\nfrom any other _remote_ or _local_ repository. The easiest way to fetch `mpls` styles from a custom style library is to\nprovide the `style_url` parameter when calling `use` or `temp`, e.g.\n```python\nimport mpls\nmpls.use(context='a4', style='thesis', style_url='http://some.other.repository.com/stylelib/{type}_{name}.json')\n```\n\nIf you want to switch the style library for a longer session, it is more convenient to change the default `stylelib_url` and `stylelib_format` in your `mpls` configuration, i.e.\n```python\nimport mpls\n...\n# switch to another remote stylelib temporarily\nmpls.configure(stylelib_url=\"http://some.other.repository.com/stylelib/\" stylelib_format=\"{type}_{name}.json\")\n\n# or switch to a local stylelib (and keep current the stylelib_format)\nmpls.configure(stylelib_url=\"~/stylelib/{type}/{name}.json\")\n```\nTwo placeholders `{type}` and `{name}` may be placed in the url. Internally, `mpls` will\nsubstitute these placeholders with the parameters provided in the frontend methods. For example, the call\n```python\nmpls.use(context='a4')\n```\nboils down to\n```python\nmpls.get(name='a4', type='context')\n```\nwhich eventually calls\n```python\nstyle_url = stylelib_url + stylelib_format.format(name=name, type=type)\n```\nto replace the placeholders in the `stylelib_format` to retrieve the actual style file url.\n\n### Make your changes permanent\nTo make your changes permanent, just provide the `save=True` parameter when switching the `stylelib_url` in the\nconfiguration or call `configure` later, i.e.\n```\n# save changes immediately\nmpls.configure(stylelib_url='~/path/to/stylelib/', save=True)\n# or configure some parameter first\nmpls.configure(stylelib_url='~/path/to/stylelib/')\n[...]\n# and save changes some later time\nmpls.configure(save=True)\n```\nThis will save your changes to the `mpls` configuration file and which is loaded every time `mpls` is initialized.\n\n## Further reading\nIf you are not convinced or just want to know a bit more about how to modify the style of your matplotlib plots, please\nrefer to the respective [matplotlib page][3] for more information on how to customize the style of your plots directly\nwith matplotlib, or visit the [seaborn][1] website to have a look at another popular matplotlib style package (and much\nmore).\n\n[1]: http://seaborn.pydata.org\n[2]: http://matplotlib.org\n[3]: http://matplotlib.org/users/customizing.html\n[4]: https://docs.python.org/3.7/library/stdtypes.html?highlight=str.format#str.format\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/scruffy-t/mpls/archive/0.2.0.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/scruffy-t/mpls", "keywords": "plotting matplotlib styles", "license": "BSD (3-clause)", "maintainer": "", "maintainer_email": "", "name": "mpls", "package_url": "https://pypi.org/project/mpls/", "platform": "", "project_url": "https://pypi.org/project/mpls/", "project_urls": { "Download": "https://github.com/scruffy-t/mpls/archive/0.2.0.tar.gz", "Homepage": "https://github.com/scruffy-t/mpls" }, "release_url": "https://pypi.org/project/mpls/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "An open library of matplotlib styles", "version": "0.2.0" }, "last_serial": 3056598, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "5c95ff6896d3e373150193a2d6ee459a", "sha256": "3df5e1529f67c1f8aec5c06569199e9671c11bee7af01f19f064dbd091703656" }, "downloads": -1, "filename": "mpls-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5c95ff6896d3e373150193a2d6ee459a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5923, "upload_time": "2017-07-25T12:17:03", "url": "https://files.pythonhosted.org/packages/1b/0a/d995b419453e4cba0deaeb25838add36ae5583451926b050b9082c58ebde/mpls-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "f2c664c588b509b47650f44e60991416", "sha256": "b0e56025ad267ba2b8601671faeb45c7fb9bb07c1bc585de2bde5581cd4fe256" }, "downloads": -1, "filename": "mpls-0.2.0.tar.gz", "has_sig": false, "md5_digest": "f2c664c588b509b47650f44e60991416", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7173, "upload_time": "2017-07-28T20:03:41", "url": "https://files.pythonhosted.org/packages/9b/8c/c42ac81c939dcacdcf29e1a37c89f6bfcd49f56fc0fb89dc69aee4165cc0/mpls-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f2c664c588b509b47650f44e60991416", "sha256": "b0e56025ad267ba2b8601671faeb45c7fb9bb07c1bc585de2bde5581cd4fe256" }, "downloads": -1, "filename": "mpls-0.2.0.tar.gz", "has_sig": false, "md5_digest": "f2c664c588b509b47650f44e60991416", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7173, "upload_time": "2017-07-28T20:03:41", "url": "https://files.pythonhosted.org/packages/9b/8c/c42ac81c939dcacdcf29e1a37c89f6bfcd49f56fc0fb89dc69aee4165cc0/mpls-0.2.0.tar.gz" } ] }