![](docs/Images/Pandas-Bokeh-Logo.png)
**Pandas-Bokeh** provides a [Bokeh](https://bokeh.pydata.org/en/latest/) plotting backend for [Pandas](https://pandas.pydata.org/), [GeoPandas](http://geopandas.org/) and [Pyspark](https://spark.apache.org/docs/latest/api/python/index.html) **DataFrames**, similar to the already existing [Visualization feature of Pandas](https://pandas.pydata.org/pandas-docs/stable/visualization.html). Importing the library adds a complementary plotting method ***plot_bokeh()*** on **DataFrames** and **Series**.
With **Pandas-Bokeh**, creating stunning, interactive, HTML-based visualization is as easy as calling:
```python
df.plot_bokeh()
```
---
**Pandas-Bokeh** also provides native support as a Pandas Plotting backend for [Pandas >= 0.25](https://pandas.pydata.org/pandas-docs/stable/whatsnew/v0.25.0.html). When **Pandas-Bokeh** is installed, switchting the default Pandas plotting backend to Bokeh can be done via:
pd.set_option('plotting.backend', 'pandas_bokeh')
More details about the new Pandas backend can be found [below.](#pandas_backend)
---
For more information have a look at the [Examples](#Examples) below or at notebooks on the [Github Repository](https://github.com/PatrikHlobil/Pandas-Bokeh/tree/master/docs) of this project.
![Startimage](docs/Images/Startimage.gif)
<br>
## Installation
You can install **Pandas-Bokeh** from [PyPI](https://pypi.org/project/pandas-bokeh/) via *pip*
pip install pandas-bokeh
or *conda*:
conda install -c patrikhlobil pandas-bokeh
With the current release 0.5, **Pandas-Bokeh** officially supports **Python 3.6** and newer. It will probably still work for older Python versions, but is not tested against these.
<br>
The current release is **0.5**. For more details, see [Release Notes](#releasenotes).
<br>
## How To Use
### Classical Use
<p id="Basics"> </p>
The **Pandas-Bokeh** library should be imported after **Pandas**, **GeoPandas** and/or **Pyspark**. After the import, one should define the plotting output, which can be:
* **pandas_bokeh.output_notebook()**: Embeds the Plots in the cell outputs of the notebook. Ideal when working in Jupyter Notebooks.
* **pandas_bokeh.output_file(filename)**: Exports the plot to the provided filename as an HTML.
For more details about the plotting outputs, see the reference [here](#Layouts) or the [Bokeh documentation](https://bokeh.pydata.org/en/latest/docs/user_guide/quickstart.html#getting-started).
#### Notebook output (see also [bokeh.io.output_notebook](https://bokeh.pydata.org/en/latest/docs/reference/io.html#bokeh.io.output_notebook))
```python
import pandas as pd
import pandas_bokeh
pandas_bokeh.output_notebook()
```
#### File output to "Interactive Plot.html" (see also [bokeh.io.output_file](https://bokeh.pydata.org/en/latest/docs/reference/io.html#bokeh.io.output_file))
```python
import pandas as pd
import pandas_bokeh
pandas_bokeh.output_file("Interactive Plot.html")
```
### **Pandas-Bokeh** as native Pandas plotting backend
<p id="pandas_backend"> </p>
For pandas >= 0.25, a plotting backend switch is natively supported. It can be achievied by calling:
import pandas as pd
pd.set_option('plotting.backend', 'pandas_bokeh')
Now, the plotting API is accessible for a Pandas DataFrame via:
df.plot(...)
All additional functionalities of **Pandas-Bokeh** are then accessible at *pd.plotting*. So, setting the output to notebook is:
pd.plotting.output_notebook()
or calling the [grid layout functionality](#dashboard_layouts):
pd.plotting.plot_grid(...)
**Note:** Backwards compatibility is kept since there will still be the *df.plot_bokeh(...)* methods for a DataFrame.
<p id="output_file"> </p>
<br>
---
### Plot types
Supported plottypes are at the moment:
* Pandas & Pyspark DataFrames
* [lineplot](#lineplot)
* [pointplot](#pointplot)
* [stepplot](#stepplot)
* [scatterplot](#scatterplot)
* [barplot](#barplot)
* [histogram](#histogram)
* [areaplot](#areaplot)
* [pieplot](#pieplot)
* [mapplot](#mapplot)
<br>
* [Geoplots (Point, Line, Polygon) with **GeoPandas**](#geoplots)
Also, check out the complementary chapter [Outputs, Formatting & Layouts](#Layouts) about:
* [Output options (how to get HTML representation of Bokeh plots)](#output_options)
* [Number formats in Pandas-Bokeh (modify Hovertool number format, suppress scientific notation on axes)](#number_formats)
* [Dashboard layouts (How to layout multiple plots in rows, columns and grids)](#dashboard_layouts)
---
<br>
<br>
<p id="Examples"></p>
## Lineplot
### Basic Lineplot
This simple **lineplot** in **Pandas-Bokeh** already contains various interactive elements:
* a pannable and zoomable (zoom in plotarea and zoom on axis) plot
* by clicking on the legend elements, one can hide and show the individual lines
* a Hovertool for the plotted lines
Consider the following simple example:
```python
import numpy as np
np.random.seed(42)
df = pd.DataFrame({"Google": np.random.randn(1000)+0.2,
"Apple": np.random.randn(1000)+0.17},
index=pd.date_range('1/1/2000', periods=1000))
df = df.cumsum()
df = df + 50
df.plot_bokeh(kind="line") #equivalent to df.plot_bokeh.line()
```
![ApplevsGoogle_1](docs/Images/ApplevsGoogle_1.gif)
Note, that similar to the regular **pandas.DataFrame.plot** method, there are also additional accessors to directly access the different plotting types like:
* ```df.plot_bokeh(kind="line", ...)``` → ```df.plot_bokeh.line(...)```
* ```df.plot_bokeh(kind="bar", ...)``` → ```df.plot_bokeh.bar(...)```
* ```df.plot_bokeh(kind="hist", ...)``` → ```df.plot_bokeh.hist(...)```
* ...
#### Advanced Lineplot
There are various optional parameters to tune the plots, for example:
* **kind**: Which kind of plot should be produced. Currently supported are: *"line", "point", "scatter", "bar"* and *"histogram"*. In the near future many more will be implemented as horizontal barplot, boxplots, pie-charts, etc.
* **x**: Name of the column to use for the horizontal x-axis. If the **x** parameter is not specified, the index is used for the x-values of the plot. Alternative, also an array of values can be passed that has the same number of elements as the DataFrame.
* **y**: Name of column *or* list of names of columns to use for the vertical y-axis.
* **figsize**: Choose width & height of the plot
* **title**: Sets title of the plot
* **xlim**/**ylim**: Set visibler range of plot for x- and y-axis (also works for *datetime x-axis*)
* **xlabel**/**ylabel**: Set x- and y-labels
* **logx**/**logy**: Set log-scale on x-/y-axis
* **xticks**/**yticks**: Explicitly set the ticks on the axes
* **color**: Defines a single color for a plot.
* **colormap**: Can be used to specify multiple colors to plot. Can be either a list of colors or the name of a [Bokeh color palette](https://bokeh.pydata.org/en/latest/docs/reference/palettes.html)
* **hovertool**: If True a Hovertool is active, else if False no Hovertool is drawn.
* **hovertool_string**: If specified, this string will be used for the hovertool (@{column} will be replaced by the value of the column for the element the mouse hovers over, see also [Bokeh documentation](https://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#custom-tooltip) and [here](#Dropdown))
* **toolbar_location**: Specify the position of the toolbar location (None, "above", "below", "left" or "right"). Default: *"right"*
* **zooming**: Enables/Disables zooming. Default: *True*
* **panning**: Enables/Disables panning. Default: *True*
* **fontsize_label/fontsize_ticks/fontsize_title/fontsize_legend**: Set fontsize of labels, ticks, title or legend (int or string of form "15pt")
* **rangetool** Enables a range tool scroller. Default *False*
* **kwargs****: Optional keyword arguments of [bokeh.plotting.figure.line](https://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.figure.Figure
没有合适的资源?快使用搜索试试~ 我知道了~
pandas-bokeh-0.5.3.tar.gz
0 下载量 137 浏览量
2024-03-06
13:09:31
上传
评论
收藏 18.65MB GZ 举报
温馨提示
共75个文件
png:18个
gif:17个
py:11个
Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。
资源推荐
资源详情
资源评论
收起资源包目录
pandas-bokeh-0.5.3.tar.gz (75个子文件)
pandas-bokeh-0.5.3
setup.py 3KB
LICENSE 1KB
PKG-INFO 3KB
tox.ini 259B
docs
ToDo.md 4KB
Documentation.ipynb 2.91MB
index.html 1.15MB
Testdata
states
states.geojson 528KB
states_population_attribution.txt 291B
epsg 835KB
energy
energy.csv 2KB
Bundestagswahl
Bundestagswahl.csv 235B
iris
iris.csv 4KB
populated places
populated_places.csv 26KB
ne_10m_populated_places_simple.VERSION.txt 6B
ne_10m_populated_places_simple_bigcities.geojson 396KB
hole_shapes
hole_shapes.geojson 952B
github-pages
make_plots.py 11KB
apply_template_theme_to_readme.py 813B
replace_pictures_with_Bokeh_plots.py 1KB
template.html 6KB
Images
Histograms_all.gif 532KB
Pointplot.gif 346KB
pieplot.gif 39KB
Startimage.png 85KB
Barplot3.png 47KB
scaled_plot.png 22KB
ApplevsGoogle_1.gif 667KB
ApplevsGoogle_3.png 31KB
US_States_2.png 326KB
Multiple_GeoLayers.gif 760KB
areaplot.png 45KB
Barplot.gif 69KB
embedded_HTML.png 74KB
Startimage.gif 541KB
Pointmap.gif 405KB
rangetool.gif 3.96MB
Barplot2.png 23KB
US_States_3.gif 757KB
US_States_4.gif 466KB
Release 0.1.png 348KB
Pandas-Bokeh-Logo.png 18KB
Scientific_axes.png 55KB
stepplot.png 48KB
US_States_1.gif 245KB
geoplot_string_tickformatter.png 258KB
Scatterplot.gif 397KB
areaplot2.gif 306KB
Alternative_Layout.png 75KB
Scatterplot2.png 45KB
Number_format.gif 249KB
geoplot_PrintfTickFormatter.png 290KB
ApplevsGoogle_2.gif 110KB
Mapplot.gif 5.46MB
Pandas-Bokeh-Logo.svg 3KB
pieplot2.png 57KB
Histogram2.png 27KB
CONTRIBUTORS.md 1KB
pandas_bokeh.egg-info
SOURCES.txt 2KB
top_level.txt 13B
PKG-INFO 3KB
requires.txt 26B
dependency_links.txt 1B
MANIFEST.in 80B
setup.cfg 67B
pandas_bokeh
__init__.py 2KB
plot.py 77KB
base.py 8KB
geoplot.py 28KB
README.md 54KB
Tests
test_GeoPandasBokeh.py 3KB
Recreate Pandas.DataFrame.plot Examples.ipynb 1.07MB
test_PandasBokeh.py 22KB
test_PySpark.py 1KB
requirements_test.txt 78B
共 75 条
- 1
资源评论
程序员Chino的日记
- 粉丝: 3025
- 资源: 4万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功