I am looking for a way to descriptively scatter a pandas.DataFrame
similar to this:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1000 entries, 0 to 999
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 type 1000 non-null object
1 value 1000 non-null int64
2 count 1000 non-null int64
dtypes: int64(2), object(1)
memory usage: 23.6+ KB
Using pandas.DataFrame.plot
or seaborn.scatterplot
, the points for each type
are all placed on one vertical line overlapping each other. To mitigate this issue I want to introduce at least some jitter in the x-direction but I don't know how.
My plots so far:
import pandas as pd
import matplotlib.pyplot as plt
import random
df = pd.DataFrame({
'type': [random.choice(['t1', 't2', 't3']) for _ in range(1000)],
'value': [random.randint(0, 500) for _ in range(1000)],
'count': [random.randint(0,250) for _ in range(1000)],
})
df.plot(kind='scatter', x='type', y='value', c='count', cmap='Blues')
plt.show()
import seaborn as sns
sns.scatterplot(x='type', y='value', data=df, hue='count')
plt.show()