Proper use of Python visualization packages

Visualization in Python is Matplotlib, but the difficulty is that the API is cluttered and difficult to remember. I feel that Bokeh is the most convenient because the API is well organized, but it is regrettable that there is still little information in Japanese. I'm hoping that Bokeh, which can support the Web, will grow in the future.

Recommended usage

--If you want to plot simple data quickly - Matplotlib --If you switch from MATLAB to Python - Matplotlib ――If you want to look cool - Bokeh --If you want to include interactive operations - Bokeh --If you want to check the numerical value of the data points on the graph - Bokeh - Plotly --If you want to plot a 3D shape - Plotly - Mayavi --For statistical analysis - seaborn

Matplotlib

good point

――It's easy to plot simple data. --The plot function is substantial (I feel). --There is more information in Japanese than others. --You can plot directly from pandas' DataFrame.plot method. - Visualization - API Reference - Series - Plotting - API Reference - DataFrame - Plotting --Since the API is similar to MATLAB, it is easy to switch from MATLAB. --The scale of the 3D plot is automatically set for each axis.

Bad points

--Japanese cannot be displayed by default. -You cannot move the graph interactively on the Notebook. (If you use % matplotlib notebook instead of% matplotlib inline, it will work, but if you close and reopen the notebook, it will not work.) --A mixture of imperative APIs and object-oriented APIs can be confusing. --The response of the interactive operation is not good. --The 3D plotting procedure is cumbersome and difficult to remember. ――It is quite troublesome to align the scale of 3 axes in 3D plot, so it is not suitable for displaying 3D shape.

Plot sample

output_1_1.png

Bokeh

good point

-You can move the graph interactively after plotting even on Notebook. --You can convert graphs that can be moved interactively into HTML and pass them on to people. - Embedding Plots and Apps --Easy to customize interactive operation - Configuring Plot Tools - Adding Widgets --Can be embedded in a website. - Running a Bokeh Server --You can dynamically update the graph with streaming data. - Updating From Threads --If you enable WebGL, you can move with good response even if you plot a large amount of data. - Speeding up with WebGL --Documents are easy to read.

Bad points

--I can't plot in 3D. --The API of the basic plotting module has to be color-coded by yourself. --The API of the charts module is roundabout to plot simple data.

Plot sample

スクリーンショット 2017-01-28 17.55.39.png Here is a sample that can be moved [Gallery — Bokeh 0.12.4 documentation](http://bokeh.pydata.org/en/latest/docs/gallery.html)

Plotly

good point

-You can move the graph interactively after plotting even on Notebook. --You can convert graphs that can be moved interactively into HTML and pass them on to people. --The function to display the numerical value of the data point is enabled by default. ――3D plotting can be done in the same procedure as 2D plotting. --The response of the 3D plot is good. --Since the scale of the 3D plot is the same for all three axes, it is suitable for displaying 3D shapes.

Other features are similar to Bokeh, but I haven't looked into them in detail.

Bad points

--It is troublesome to specify the size of the graph. --I don't know how to display a 3D plot on a different scale for each axis. --There is very little information. --Some functions are charged (Streaming seems to be charged) --Documents are hard to see. --The explanation of docstring is short. --Most of the sample code uses the paid version of the API. --Cannot search in official documents.

Plot sample

スクリーンショット 2017-02-02 23.44.25.png Here is a sample that can be run [Python Graphing Library, Plotly](https://plot.ly/python/)

Note: How to get the sample code to work with the free version

If you replace ʻimport plotly.plotly as py with ʻimport plotly.offline as py, it should work.

Mayavi

good point

--Since it is exclusively for 3D plotting, it has a full range of 3D plotting functions. --You can change the settings after plotting. --There is a Japanese tutorial on 3D plotting. -3.5. 3D plot by Mayavi — Scipy lecture notes

Bad points

--Installation is troublesome because it does not support PyQt5 --It does not work by default in the root environment of Anaconda 4.3.0. --You need to specify the version and install PyQt4. --conda update --all is NG (updated to PyQt5) --By default, the axes are not displayed. -Although it can be displayed on the Notebook, its functions are quite limited.

seaborn

good point

--There are many ultra-high level APIs that specialize in statistical analysis --lmplot: Regression and plot at once - seaborn.lmplot --joinplot: A combination of a two-variable scatter plot and a histogram - seaborn.jointplot --pairplot: Collecting multivariable scatter plots - seaborn.pairplot --Jitter is convenient (a function to plot overlapping points that are difficult to see with a slight shift) --Jitter example: seaborn.stripplot

Bad points

--The style of Matplotlib is changed without permission just by importing.

Reference link

Jupyter-notebook drawing library comparison-Qiita Cheat sheet for displaying anything on Jupyter Notebook --Qiita

Recommended Posts

Proper use of Python visualization packages
[ns3-30] Enable visualization of Python scripts
[Python Queue] Convenient use of Deque
[Python] Summary of how to use pandas
[Python2.7] Summary of how to use unittest
(Note) Bulk upgrade of python installed packages
List of Atom packages I really use
Recommendation of Altair! Data visualization with Python
Summary of how to use Python list
[Python2.7] Summary of how to use subprocess
[Question] How to use plot_surface of python
Introduction of Python
Basics of Python ①
Basics of python ①
Copy of python
Introduction of Python
How to use folium (visualization of location information)
[Python] How to use two types of type ()
Real-time visualization of thermography AMG8833 data in Python
Use multiple versions of python environment with pyenv
Use OpenSeesPy regardless of OS or Python version
Summary of how to use MNIST in Python
python development environment -use of pyenv and virtualenv-
Summary of studying Python to use AWS Lambda
Let's use different versions of SQLite3 from Python3!
Convenient use of ipython
Use data class for data storage of Python 3.7 or higher
Use thingsspeak from python
[Python] Operation of enumerate
List of python modules
Use config.ini in Python
[Python] Use JSON with Python
Use fluentd from python
I tried to summarize how to use matplotlib of python
Power BI visualization of Salesforce data entirely in Python
Visualization memo by Python
Use dates in Python
Python Data Visualization Libraries
Unification of Python environment
Copy of python preferences
Basics of Python scraping basics
[python] behavior of argmax
Python packages and modules
Use Valgrind in Python
Python --Explanation and usage summary of the top 24 packages
Use MySQL from Python
Use urlparse.urljoin instead of os.path.join for Python URL joins
Use mecab with Python3
Use LiquidTap Python Client ③
Various Python visualization tools
Usage of Python locals ()
the zen of Python
Use DynamoDB with Python
Graceful use of MySQLdb
Installation of Python 3.3 rc1
How to use Python Kivy ① ~ Basics of Kv Language ~
Using Python #external packages
Let's use the Python version of the Confluence API module.
Use Python 3.8 with Anaconda
[Python] format methodical use
Use python with docker