Bowen Peng
Bowen Peng

Reputation: 1825

How to change the data for x-axis and y-axis in sns.distplot

I get a pd.series as follows:

train_df['area'] 

0     68.06
1    125.55
2    132.00
3     57.00
4    129.00
5    223.35
6     78.94
7     76.00
Name: area, dtype: float64

And I draw the sns.distplot() of it, but I get a plot as follows:

sns.distplot

BUT, what I really want is that x-axis and y-axis should be [0, 1,...,7] and [40, 60,..., 240].
I am wondering how to fix it?
. If not mind, could anyone help me?
Thanks in advance.

Upvotes: 0

Views: 1497

Answers (1)

Quang Hoang
Quang Hoang

Reputation: 150785

Try to use plt's axis:

fig, ax = plt.subplots(1,1)

# pass ax here
sns.distplot(..., ax=ax)
ax.set_xticklabels(range(8))
ax.set_yticklabels(ax.get_yticks()*20000+40)
plt.show()

Output:

enter image description here

Upvotes: 1

Related Questions