Name | plotnine JSON |
Version |
0.14.6
JSON |
| download |
home_page | None |
Summary | A Grammar of Graphics for Python |
upload_time | 2025-06-25 14:59:32 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | The MIT License (MIT)
Copyright (c) 2022 Hassan Kibirige
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 |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# plotnine <img width="20%" align="right" src="https://github.com/has2k1/plotnine/blob/logos/doc/images/logo-512.png?raw=true">
[](https://pypi.python.org/pypi/plotnine)
[](https://pypi.python.org/pypi/plotnine)
[](https://zenodo.org/badge/latestdoi/89276692)
[](https://github.com/has2k1/plotnine/actions?query=branch%3Amain+workflow%3A%22build%22)
[](https://codecov.io/github/has2k1/plotnine?branch=main)
plotnine is an implementation of a *grammar of graphics* in Python
based on [ggplot2](https://github.com/tidyverse/ggplot2).
The grammar allows you to compose plots by explicitly mapping variables in a
dataframe to the visual characteristics (position, color, size etc.) of objects that make up the plot.
Plotting with a *grammar of graphics* is powerful. Custom (and otherwise
complex) plots are easy to think about and build incrementally, while the
simple plots remain simple to create.
To learn more about how to use plotnine, check out the
[documentation](https://plotnine.org). Since plotnine
has an API similar to ggplot2, where it lacks in coverage the
[ggplot2 documentation](http://ggplot2.tidyverse.org/reference/index.html)
may be helpful.
## Example
```python
from plotnine import *
from plotnine.data import mtcars
```
Building a complex plot piece by piece.
1. Scatter plot
```python
(
ggplot(mtcars, aes("wt", "mpg"))
+ geom_point()
)
```
<img width="90%" align="center" src="https://github.com/has2k1/plotnine/blob/logos/doc/images/readme-image-1.png?raw=true">
2. Scatter plot colored according some variable
```python
(
ggplot(mtcars, aes("wt", "mpg", color="factor(gear)"))
+ geom_point()
)
```
<img width="90%" align="center" src="https://github.com/has2k1/plotnine/blob/logos/doc/images/readme-image-2.png?raw=true">
3. Scatter plot colored according some variable and
smoothed with a linear model with confidence intervals.
```python
(
ggplot(mtcars, aes("wt", "mpg", color="factor(gear)"))
+ geom_point()
+ stat_smooth(method="lm")
)
```
<img width="90%" align="center" src="https://github.com/has2k1/plotnine/blob/logos/doc/images/readme-image-3.png?raw=true">
4. Scatter plot colored according some variable,
smoothed with a linear model with confidence intervals and
plotted on separate panels.
```python
(
ggplot(mtcars, aes("wt", "mpg", color="factor(gear)"))
+ geom_point()
+ stat_smooth(method="lm")
+ facet_wrap("gear")
)
```
<img width="90%" align="center" src="https://github.com/has2k1/plotnine/blob/logos/doc/images/readme-image-4.png?raw=true">
5. Adjust the themes
I) Make it playful
```python
(
ggplot(mtcars, aes("wt", "mpg", color="factor(gear)"))
+ geom_point()
+ stat_smooth(method="lm")
+ facet_wrap("gear")
+ theme_xkcd()
)
```
<img width="90%" align="center" src="https://github.com/has2k1/plotnine/blob/logos/doc/images/readme-image-5.png?raw=true">
II) Or professional
```python
(
ggplot(mtcars, aes("wt", "mpg", color="factor(gear)"))
+ geom_point()
+ stat_smooth(method="lm")
+ facet_wrap("gear")
+ theme_tufte()
)
```
<img width="90%" align="center" src="https://github.com/has2k1/plotnine/blob/logos/doc/images/readme-image-5alt.png?raw=true">
## Installation
Official release
```console
# Using pip
$ pip install plotnine # 1. should be sufficient for most
$ pip install 'plotnine[extra]' # 2. includes extra/optional packages
$ pip install 'plotnine[test]' # 3. testing
$ pip install 'plotnine[doc]' # 4. generating docs
$ pip install 'plotnine[dev]' # 5. development (making releases)
$ pip install 'plotnine[all]' # 6. everything
# Or using conda
$ conda install -c conda-forge plotnine
```
Development version
```console
$ pip install git+https://github.com/has2k1/plotnine.git
```
## Contributing
Our documentation could use some examples, but we are looking for something
a little bit special. We have two criteria:
1. Simple looking plots that otherwise require a trick or two.
2. Plots that are part of a data analytic narrative. That is, they provide
some form of clarity showing off the `geom`, `stat`, ... at their
differential best.
If you come up with something that meets those criteria, we would love to
see it. See [plotnine-examples](https://github.com/has2k1/plotnine-examples).
If you discover a bug checkout the [issues](https://github.com/has2k1/plotnine/issues)
if it has not been reported, yet please file an issue.
And if you can fix a bug, your contribution is welcome.
Testing
-------
Plotnine has tests that generate images which are compared to baseline images known
to be correct. To generate images that are consistent across all systems you have
to install matplotlib from source. You can do that with ``pip`` using the command.
```console
$ pip install matplotlib --no-binary matplotlib
```
Otherwise there may be small differences in the text rendering that throw off the
image comparisons.
Raw data
{
"_id": null,
"home_page": null,
"name": "plotnine",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Hassan Kibirige <has2k1@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/09/fd/ce17b0ab56f1a4ea973b1614d64951a9520919da93f0ae407ea48feecc2d/plotnine-0.14.6.tar.gz",
"platform": null,
"description": "# plotnine <img width=\"20%\" align=\"right\" src=\"https://github.com/has2k1/plotnine/blob/logos/doc/images/logo-512.png?raw=true\">\n\n[](https://pypi.python.org/pypi/plotnine)\n[](https://pypi.python.org/pypi/plotnine)\n[](https://zenodo.org/badge/latestdoi/89276692)\n[](https://github.com/has2k1/plotnine/actions?query=branch%3Amain+workflow%3A%22build%22)\n[](https://codecov.io/github/has2k1/plotnine?branch=main)\n\nplotnine is an implementation of a *grammar of graphics* in Python\nbased on [ggplot2](https://github.com/tidyverse/ggplot2).\nThe grammar allows you to compose plots by explicitly mapping variables in a\ndataframe to the visual characteristics (position, color, size etc.) of objects that make up the plot.\n\nPlotting with a *grammar of graphics* is powerful. Custom (and otherwise\ncomplex) plots are easy to think about and build incrementally, while the\nsimple plots remain simple to create.\n\nTo learn more about how to use plotnine, check out the\n[documentation](https://plotnine.org). Since plotnine\nhas an API similar to ggplot2, where it lacks in coverage the\n[ggplot2 documentation](http://ggplot2.tidyverse.org/reference/index.html)\nmay be helpful.\n\n\n## Example\n\n```python\nfrom plotnine import *\nfrom plotnine.data import mtcars\n```\n\nBuilding a complex plot piece by piece.\n\n1. Scatter plot\n\n ```python\n (\n ggplot(mtcars, aes(\"wt\", \"mpg\"))\n + geom_point()\n )\n ```\n\n <img width=\"90%\" align=\"center\" src=\"https://github.com/has2k1/plotnine/blob/logos/doc/images/readme-image-1.png?raw=true\">\n\n2. Scatter plot colored according some variable\n\n ```python\n (\n ggplot(mtcars, aes(\"wt\", \"mpg\", color=\"factor(gear)\"))\n + geom_point()\n )\n ```\n\n <img width=\"90%\" align=\"center\" src=\"https://github.com/has2k1/plotnine/blob/logos/doc/images/readme-image-2.png?raw=true\">\n\n3. Scatter plot colored according some variable and\n smoothed with a linear model with confidence intervals.\n\n ```python\n (\n ggplot(mtcars, aes(\"wt\", \"mpg\", color=\"factor(gear)\"))\n + geom_point()\n + stat_smooth(method=\"lm\")\n )\n ```\n\n <img width=\"90%\" align=\"center\" src=\"https://github.com/has2k1/plotnine/blob/logos/doc/images/readme-image-3.png?raw=true\">\n\n4. Scatter plot colored according some variable,\n smoothed with a linear model with confidence intervals and\n plotted on separate panels.\n\n ```python\n (\n ggplot(mtcars, aes(\"wt\", \"mpg\", color=\"factor(gear)\"))\n + geom_point()\n + stat_smooth(method=\"lm\")\n + facet_wrap(\"gear\")\n )\n ```\n\n <img width=\"90%\" align=\"center\" src=\"https://github.com/has2k1/plotnine/blob/logos/doc/images/readme-image-4.png?raw=true\">\n\n5. Adjust the themes\n\n\n I) Make it playful\n\n ```python\n (\n ggplot(mtcars, aes(\"wt\", \"mpg\", color=\"factor(gear)\"))\n + geom_point()\n + stat_smooth(method=\"lm\")\n + facet_wrap(\"gear\")\n + theme_xkcd()\n )\n ```\n\n <img width=\"90%\" align=\"center\" src=\"https://github.com/has2k1/plotnine/blob/logos/doc/images/readme-image-5.png?raw=true\">\n\n II) Or professional\n\n ```python\n (\n ggplot(mtcars, aes(\"wt\", \"mpg\", color=\"factor(gear)\"))\n + geom_point()\n + stat_smooth(method=\"lm\")\n + facet_wrap(\"gear\")\n + theme_tufte()\n )\n ```\n\n <img width=\"90%\" align=\"center\" src=\"https://github.com/has2k1/plotnine/blob/logos/doc/images/readme-image-5alt.png?raw=true\">\n\n## Installation\n\nOfficial release\n\n```console\n# Using pip\n$ pip install plotnine # 1. should be sufficient for most\n$ pip install 'plotnine[extra]' # 2. includes extra/optional packages\n$ pip install 'plotnine[test]' # 3. testing\n$ pip install 'plotnine[doc]' # 4. generating docs\n$ pip install 'plotnine[dev]' # 5. development (making releases)\n$ pip install 'plotnine[all]' # 6. everything\n\n# Or using conda\n$ conda install -c conda-forge plotnine\n```\n\nDevelopment version\n\n```console\n$ pip install git+https://github.com/has2k1/plotnine.git\n```\n\n## Contributing\n\nOur documentation could use some examples, but we are looking for something\na little bit special. We have two criteria:\n\n1. Simple looking plots that otherwise require a trick or two.\n2. Plots that are part of a data analytic narrative. That is, they provide\n some form of clarity showing off the `geom`, `stat`, ... at their\n differential best.\n\nIf you come up with something that meets those criteria, we would love to\nsee it. See [plotnine-examples](https://github.com/has2k1/plotnine-examples).\n\nIf you discover a bug checkout the [issues](https://github.com/has2k1/plotnine/issues)\nif it has not been reported, yet please file an issue.\n\nAnd if you can fix a bug, your contribution is welcome.\n\nTesting\n-------\n\nPlotnine has tests that generate images which are compared to baseline images known\nto be correct. To generate images that are consistent across all systems you have\nto install matplotlib from source. You can do that with ``pip`` using the command.\n\n```console\n$ pip install matplotlib --no-binary matplotlib\n```\n\nOtherwise there may be small differences in the text rendering that throw off the\nimage comparisons.\n",
"bugtrack_url": null,
"license": "The MIT License (MIT)\n \n Copyright (c) 2022 Hassan Kibirige\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n ",
"summary": "A Grammar of Graphics for Python",
"version": "0.14.6",
"project_urls": {
"changelog": "https://plotnine.readthedocs.io/en/stable/changelog.html",
"ci": "https://github.com/has2k1/plotnine/actions",
"homepage": "https://plotnine.readthedocs.io/en/stable",
"repository": "https://github.com/has2k1/plotnine"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "194e72403df4448bd9f1fc55b2adbc3f7dffea89f2a2ed8a480a29edccb35bcb",
"md5": "c4ceb4bb6a3168aca0c52b58ddd89de0",
"sha256": "45d66970a8dbc679258cc9f03ef046c26c985df7723ba0417297d18dcca9f1fd"
},
"downloads": -1,
"filename": "plotnine-0.14.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c4ceb4bb6a3168aca0c52b58ddd89de0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 1301245,
"upload_time": "2025-06-25T14:59:30",
"upload_time_iso_8601": "2025-06-25T14:59:30.758941Z",
"url": "https://files.pythonhosted.org/packages/19/4e/72403df4448bd9f1fc55b2adbc3f7dffea89f2a2ed8a480a29edccb35bcb/plotnine-0.14.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "09fdce17b0ab56f1a4ea973b1614d64951a9520919da93f0ae407ea48feecc2d",
"md5": "45dae14381b7210a7639d7342f176102",
"sha256": "6e4d1cd17d360c18a3fccf9d838d5fa17859d29b6c1d722fa6f9bec89f269504"
},
"downloads": -1,
"filename": "plotnine-0.14.6.tar.gz",
"has_sig": false,
"md5_digest": "45dae14381b7210a7639d7342f176102",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 6424681,
"upload_time": "2025-06-25T14:59:32",
"upload_time_iso_8601": "2025-06-25T14:59:32.603984Z",
"url": "https://files.pythonhosted.org/packages/09/fd/ce17b0ab56f1a4ea973b1614d64951a9520919da93f0ae407ea48feecc2d/plotnine-0.14.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-06-25 14:59:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "has2k1",
"github_project": "plotnine",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "plotnine"
}