Reputation: 3
I have some data and need to generate a plot like this image, I just wonder how to do this using python seaborn scatter plot? Thanks, heaps! example:
Upvotes: 0
Views: 4512
Reputation: 262359
Here is a minimal example using seaborn.scatterplot
:
import pandas as pd
import seaborn as sns
import numpy as np
np.random.seed(0)
df1 = pd.DataFrame({'x': np.random.random(size=10),
'y1': np.random.random(size=10),
})
df2 = pd.DataFrame({'x': np.random.random(size=10),
'y2': np.random.random(size=10)*100,
})
ax1 = plt.subplot()
ax2 = ax1.twinx()
sns.scatterplot(data=df1, x='x', y='y1', ax=ax1)
sns.scatterplot(data=df2, x='x', y='y2', color='r', ax=ax2)
ax2.tick_params(axis='y', colors='red')
output:
Upvotes: 4