Draw a scatterplot matrix in python

Overview

Use the pairs function to draw a scatterplot matrix in R.

pairs(iris[1:4], main = "Edgar Anderson's Iris Data", pch = 21, bg = c("red", "green3", "blue")[unclass(iris$Species)])

rmatrix.png

I tried to draw this with python, but it seems that the familiar matplotlib does not implement a function to draw a scatterplot matrix.

You can implement it by making full use of subplot, but here, draw a scatter plot matrix using a graph drawing library called seaborn. I will show you how.

Dependency matplotlib (>=1.4) seaborn (>=0.5) Both should be installable with pip.

Source code

import matplotlib.pyplot as plt
import seaborn as sns

df = sns.load_dataset("iris")
sns.pairplot(df, hue="species", size=2.5)
plt.show()

Execution result

figure_1.png

Other

seaborn has other tools for drawing various cool graphs. If you are tired of matplotlib graphs, please use it.

reference

Scatterplot Matrix

Recommended Posts

Draw a scatterplot matrix in python
Draw a heart in Python
Draw a CNN diagram in Python
Draw a heart in Python Part 2 (SymPy)
Draw a tree in Python 3 using graphviz
Draw graph in python
Draw a graph of a quadratic function in Python
[Python] How to draw a histogram in Matplotlib
[Python] Find the transposed matrix in a comprehension
Take a screenshot in Python
Create a function in Python
Draw mp3 waveform in Python
Create a dictionary in Python
Draw Poincare's disk in Python
Matrix multiplication in python numpy
Transposed matrix in Python standard
Draw "Draw Ferns Programmatically" in Python
Make a bookmarklet in Python
Draw implicit function in python
Draw Sine Waves in Blender Python
Maybe in a python (original title: Maybe in Python)
Write a binary search in Python
[python] Manage functions in a list
Hit a command in Python (Windows)
Create a DI Container in Python
Draw knots interactively in Plotly (Python)
ABC166 in Python A ~ C problem
Write A * (A-star) algorithm in Python
Create a binary file in Python
Solve ABC036 A ~ C in Python
Write a pie chart in Python
Write a vim plugin in Python
Write a depth-first search in Python
Implementing a simple algorithm in Python 2
Create a Kubernetes Operator in Python
Solve ABC037 A ~ C in Python
Run a simple algorithm in Python
When creating a matrix in a list
Create a random string in Python
Find the eigenvalues of a real symmetric matrix in Python
Schedule a Zoom meeting in Python
When writing a program in Python
Draw a watercolor illusion with edge detection in Python3 and openCV3
Generate a first class collection in Python
Spiral book in Python! Python with a spiral book! (Chapter 14 ~)
Solve ABC175 A, B, C in Python
Use print in a Python2 lambda expression
A simple HTTP client implemented in Python
Precautions when pickling a function in python
Write the test in a python docstring
Display a list of alphabets in Python 3
Try sending a SYN packet in Python
Try drawing a simple animation in Python
Create a simple GUI app in Python
Draw a heart in Ruby with PyCall
Draw Nozomi Sasaki in Excel with python
Create a JSON object mapper in Python
Write a short property definition in Python
[Python] [Windows] Take a screen capture in Python
Run the Python interpreter in a script
How to get a stacktrace in python