Python Forum

Full Version: How to plot multiple scatter plots in seaborn
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi Python users,

I'm a beginner and wondering if anyone can help with advice on how to plot multiple scatterplots using a loop

import pandas as pd
import matplotlib as plt
import seaborn as sns, numpy as np
import matplotlib.pyplot as plt
data = pd.read_stata('theta_se_matrix.dta')
sns.pairplot(data, kind="scatter", diag_kind="kde", vars=["theta1", "theta2", "theta3", "theta4", "theta5", "theta6"], hue="method")
plt.show()
I want to plot separate graphs for each category of "method'

Thanks
Unfortunately, I don't understand the question. line 6 in your code plots a 6x6 grid of axes with probability density estimations on the main diagonal of the grid. hue parameter just makes all graphs colored. If you need to customize pairplot function, you can use PairGrid class .
The scatter graph is colored based on the hue parameter, but I want separate graphs for each category of the hue parameter.

in my Stata code, what I wanted to graph in Python is implemented as;

forv i=2/7 {
foreach s in theta se {
graph matrix 's'1 's'2 's'3 's'4 's'5 's'6 if method=='i'
}
}

Any help on how to implement in Python will be appreciated