{ "info": { "author": "andrzejnovak", "author_email": "novak5andrzej@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "

\n \n

\n\n[![Build Status](https://travis-ci.org/andrzejnovak/mplhep.svg?branch=master)](https://travis-ci.org/andrzejnovak/mplhep) ![Hits](https://countimports.pythonanywhere.com/nocount/tag.svg?url=count_mplhep_imports)\n\nA set of helpers for `matplotlib` to more easily produce plots typically\nneeded in HEP as well as style them in way that's compatible with current\ncollaboration requirements (ROOT).\n\n\n# Installation\n```\npip install mplhep\n```\n# Basic use\n\n## Styling\n```\nimport matplotlib.pyplot as plt\nimport mplhep as hep\nplt.style.use(hep.style.ROOT)\n```\nStyles are also included in experiment specific helpers along with other styling\nhelper functions.\n```\nplt.style.use(hep.cms.style.ROOT)\nplt.style.use(hep.atlas.style.ATLAS)\n```\n#### Minimal Example\n```diff\nimport numpy as np\nimport matplotlib.pyplot as plt\n+ import mplhep as hep\n\nx = np.random.uniform(0, 10, 240)\ny = np.random.normal(512, 112, 240)\nz = np.random.normal(0.5, 0.1, 240)\n\n+ plt.style.use(hep.style.ROOT)\nf, ax = plt.subplots()\nax.scatter(x,y, c=z);\n\n```\n\n

\n \n \n

\n*(gray padded to see figure size)\n\n## Plotting\nA pre-binned histogram plotter is provided, as this functionality is currently\nawkward in `mpl`.\n\n```diff\nimport numpy as np\nimport matplotlib.pyplot as plt\n+ import mplhep as hep\n\nh, bins = np.histogram(np.random.normal(10,3,1000))\n\nf, ax = plt.subplots()\n- ax.step(bins, np.r_[h, h[-1]], step='post')\n+ hep.histplot(h, bins)\n\n```\nAdditinal functionality is also wrapped inside.\n- if `h` is a list of arrays or a 2d array, separate histograms will be plotted\n- `stack=True` stack plots\n- `yerr={None | True | array of ndim = h.ndim | array of ndim = h.ndim + 1}` is\navailable to plot `{ no | Poisson | one-sided | two-sided }` errors.\n- `density=True` show density\n- `weights`\n- `histype={'step' | 'fill'}`\n- `edges` when plotting with `'step'` close the shape outside\n\nAn effort has been made to provide API as close as possible to `plt.hist()`\n\n### 2D Histogram plotter is also included\n\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport mplhep as hep\n\nfig, ax = plt.subplots()\n\nxedges = [0, 1, 3, 5]\nyedges = [0, 2, 3, 4, 6,7]\nx = np.random.normal(2, 1, 100)\ny = np.random.normal(4, 1, 100)\nH, xedges, yedges = np.histogram2d(x, y, bins=(xedges, yedges))\nH = H.T\n\nhep.hist2dplot(H, xedges, yedges)\n\n```\n\n# More Information\n\n### Available styles:\n\n- `plt.style.use(style.ROOT)` - Default (figure 10x10 inches, full column size)\n- `plt.style.use(style.ROOTlegacy)` - Same as ROOT stylele above, but use ROOT fonts - Helvetica, fallback to Arial - instead of TeX Gyre Heros, requires font to be already available on the system\n- `plt.style.use(style.ROOTs)` - Default (figure 6x6 inches, half column size)\n- `plt.style.use(style.fira)` - use Fira Sans\n\n- `plt.style.use(style.firamath)` - use Fira Math\n\n- `plt.style.use(style.ATLAS)` - use default ATLAS style from https://github.com/kratsg/ATLASstylempl, note it defaults to Helvetica, which is not supplied in this package as explained below, and will only work properly if already available on the system\n\n#### Styles can be chained:\n- e.g. `plt.style.use([style.ROOT, style.fira, style.firamath])`\n- reappearing rcParams get overwritten silently\n\n#### Styles can be modified on the fly\n- Since styles are dictionaries and they can be chained/overwritten they can be easiely modified on the fly. e.g.\n```\nplt.style.use(style.ROOT)\nplt.style.use({\"font.sans-serif\":'Comic Sans MS'})\n```\n\n#### Styling with LaTeX\n- `plt.style.use(style.ROOTtex)` - Use LaTeX to produce all text labels\n- Requires having the full tex-live distro\n- True Helvetica\n- Use sansmath as the math font\n- Takes longer and not always better\n- In general more possibilities, but a bit more difficult to get everything working properly\n\n## Experiment annotations\n```diff\n+ plt.style.use(hep.cms.style.ROOT)\n+ ax = hep.cms.cmslabel(ax, data=False, paper=False, year='2017')\n```\n

\n \n \n

\n\n\n## Plot helper functions\n\n#### Box (or other) aspect\n\n#### Square plot with subplot (works with `tight_layout()`)\n\n#### Append a new axes, without modifying the original\n\n# Notes\n\n## Consistency \\& Fonts\nAs it is ROOT does not come with any fonts and therefore relies on using system fonts. Therfore the font in a figure can be dependent on whether it was produced on OSX or PC. The default sans-serif font used is Helvetica, but it only comes with OSX, in Windows this will silently fallback to Arial.\n\n### License\nBoth Helvetica and Arial are proprietary, which as far as fonts go means you can use it to create any text/graphics once you have the license, but you cannot redistribute the font files as part of other software. That means we cannot just package Helvetica with this to make sure everyone has the same font in plots.\n\nLuckily for fonts it seems only the software is copyrighted, not the actual shapes, which means there are quite a few open alternatives with similar look. The most closely resembling Helvetica being Tex Gyre Heros\n\n#### Tex Gyre Heros\nhttp://www.gust.org.pl/projects/e-foundry/tex-gyre/heros\n\nYou can compare yourself if the differences are meanigful below.\n\n

\n \n

\n\nThey are Tex Gyre Heros, Helvetica and Arial respecively.\n\n### Math Fonts\n- Math fonts are a separate set from regular fonts due to the amount of special characters\n- It's not trivial to make sure you get a matching math font to your regular font\n- Most math-fonts are serif fonts, but this is not ideal if one wants to use sans-serif font for normal text like Helvetica or Arial\n- The number of sans-serif math-fonts is very limited\n \t- The number of **open** sans-serif math-fonts is **extremely** limited\n \t- Basically there's two, Fira Sans and GFS Neohellenic Math, of which I like Fira Sans better\n \t- https://tex.stackexchange.com/questions/374250/are-there-opentype-sans-math-fonts-under-development\n\nFor consistent styling Fira Sans is included as well.\n#### Default Fira Sans\nhttps://github.com/mozilla/Fira\n#### Math font extension\nhttps://github.com/firamath/firamath\n\n## What doesn't work\n\n### Context styles and fonts\n```\nwith pyplot.style.context(style.ROOT):\n plotting...\n```\n- This syntax would be ideal, however, it doesn't work properly for fonts and there are no plans by mpl devs to fix this behaviour https://github.com/matplotlib/matplotlib/issues/11673\n\nFor now one has to set the style globally\n```\nplt.style.use(style.ROOT)\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/andrzejnovak/mplhep/", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "mplhep", "package_url": "https://pypi.org/project/mplhep/", "platform": "", "project_url": "https://pypi.org/project/mplhep/", "project_urls": { "Homepage": "https://github.com/andrzejnovak/mplhep/" }, "release_url": "https://pypi.org/project/mplhep/0.0.11/", "requires_dist": null, "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "summary": "Matplotlib styles for HEP", "version": "0.0.11" }, "last_serial": 5996171, "releases": { "0.0.10": [ { "comment_text": "", "digests": { "md5": "cbbbb626ffff1973eb49dace8245569e", "sha256": "7b49d93f35bd926e38864d32d596fd5c67fe9570f1f46510934a3cdc1dc19d10" }, "downloads": -1, "filename": "mplhep-0.0.10.tar.gz", "has_sig": false, "md5_digest": "cbbbb626ffff1973eb49dace8245569e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 6275922, "upload_time": "2019-10-18T10:11:20", "url": "https://files.pythonhosted.org/packages/98/84/8d43acd036a815abc7ece5ad3db548c708ad11279d267afd254951321a0f/mplhep-0.0.10.tar.gz" } ], "0.0.11": [ { "comment_text": "", "digests": { "md5": "7292230c76c08cb9485a5a9a508a1591", "sha256": "ffb323cef7a3f2f642c4b539870ce9cfabc5db6b0ce967f2cd3ee50b1fb91d4c" }, "downloads": -1, "filename": "mplhep-0.0.11.tar.gz", "has_sig": false, "md5_digest": "7292230c76c08cb9485a5a9a508a1591", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 6273071, "upload_time": "2019-10-18T15:23:17", "url": "https://files.pythonhosted.org/packages/ff/ef/f00b74a3027a4ece7661c3dda8431d36392240e06dbd31cba146d0e05159/mplhep-0.0.11.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "3a15366873225de68e7bd5821d04e63f", "sha256": "f912d8874eb9a2c1d4d05a696d31306b16f3f7c596e5a60de640fb3e0d33745f" }, "downloads": -1, "filename": "mplhep-0.0.2.tar.gz", "has_sig": false, "md5_digest": "3a15366873225de68e7bd5821d04e63f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10951, "upload_time": "2019-08-29T19:56:25", "url": "https://files.pythonhosted.org/packages/02/65/d9edf34bd4b9892bad8f50f8a8aba1376be11bf35fb974939c33b69228eb/mplhep-0.0.2.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "0352cb22ad02d0141ae53f484f81d658", "sha256": "639f51a060ba5d924b6ce706c477ba79f4a9173e98d53a47c2bfaa0c99343e7e" }, "downloads": -1, "filename": "mplhep-0.0.4.tar.gz", "has_sig": false, "md5_digest": "0352cb22ad02d0141ae53f484f81d658", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11028, "upload_time": "2019-08-29T20:36:42", "url": "https://files.pythonhosted.org/packages/e4/52/93d5596b1db252960f6fc2714f7e2df0b9ad5969769a8893196340756adc/mplhep-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "b915b1f8d1ce7d7cc8dc0e1e03965a52", "sha256": "a8971bc925290e197c6ab190235f0cbfca134692aa0e1fc2c7e6032be9dacda9" }, "downloads": -1, "filename": "mplhep-0.0.5.tar.gz", "has_sig": false, "md5_digest": "b915b1f8d1ce7d7cc8dc0e1e03965a52", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12385, "upload_time": "2019-10-02T15:22:00", "url": "https://files.pythonhosted.org/packages/fe/38/9020bac3c50ade85635f472b0012b36b779eb8d65c0980b8dec1178fd49d/mplhep-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "c5778182650061af735272241f689411", "sha256": "55733e895a332eba381f31a8550e3a18aa96e4fba1c34150133bf154e3f78a70" }, "downloads": -1, "filename": "mplhep-0.0.6.tar.gz", "has_sig": false, "md5_digest": "c5778182650061af735272241f689411", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6279735, "upload_time": "2019-10-06T17:41:06", "url": "https://files.pythonhosted.org/packages/e4/0f/29d599ba82afec9ff4afb88b627e217d840f0bd1d81c6df3e246cb220957/mplhep-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "87efdd4c945e5339ae82502ab772fd13", "sha256": "297a3895e0b06dc6924d62ca76f742fbff63be90a6175e18648dbf6e44462da3" }, "downloads": -1, "filename": "mplhep-0.0.7.tar.gz", "has_sig": false, "md5_digest": "87efdd4c945e5339ae82502ab772fd13", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6277955, "upload_time": "2019-10-07T12:52:00", "url": "https://files.pythonhosted.org/packages/3d/c9/252c8055c5b7cf20e6e48da24405a3657618c545c30b99a9186553b9a6d7/mplhep-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "dbfc0b0e6c6135b047b36cb2e220723f", "sha256": "5ad6aa53cb87d7519d50b1a70350efd4ed2af7122ee4ee44b66892cc22508396" }, "downloads": -1, "filename": "mplhep-0.0.8.tar.gz", "has_sig": false, "md5_digest": "dbfc0b0e6c6135b047b36cb2e220723f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6278201, "upload_time": "2019-10-07T13:02:58", "url": "https://files.pythonhosted.org/packages/90/a2/9e75b69839cef4567310f48a4fa6885f2ccf9ad227ea6fd2f7a7873548e5/mplhep-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "23af7bd9c8381dfb2c5ce17434f82e9b", "sha256": "369c980bf3cea1990b8d4467624202c82790df0821306781ed504b4b58040abf" }, "downloads": -1, "filename": "mplhep-0.0.9.tar.gz", "has_sig": false, "md5_digest": "23af7bd9c8381dfb2c5ce17434f82e9b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 6275902, "upload_time": "2019-10-18T10:08:21", "url": "https://files.pythonhosted.org/packages/c7/1e/f9d090d579d4949b2adccd311dabc15352b6412769aacd46c70a7be8836d/mplhep-0.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7292230c76c08cb9485a5a9a508a1591", "sha256": "ffb323cef7a3f2f642c4b539870ce9cfabc5db6b0ce967f2cd3ee50b1fb91d4c" }, "downloads": -1, "filename": "mplhep-0.0.11.tar.gz", "has_sig": false, "md5_digest": "7292230c76c08cb9485a5a9a508a1591", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 6273071, "upload_time": "2019-10-18T15:23:17", "url": "https://files.pythonhosted.org/packages/ff/ef/f00b74a3027a4ece7661c3dda8431d36392240e06dbd31cba146d0e05159/mplhep-0.0.11.tar.gz" } ] }