2017-08-04 77 views
2

我正在上使用udacity ML纳米程度的波士顿住房项目更改在直方图轴单位的下列data set使用seaborn

我使用seabron绘制数据的直方图:

df = pd.read_csv('housing.csv') 
sns.distplot(df['MEDV']) 

enter image description here

它看起来不错,但我不喜欢轴的规模,这是难以阅读。 如何在千位和Y轴10e-3上设置x轴?

回答

2

你应该能够做到这一点使用matplotlib.pyplot.ticklabel_format:

import matplotlib.pyplot as plt 
df = pd.read_csv('housing.csv') 
g = sns.distplot(df['MEDV']) 
plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0)) 

Output Image

让我知道,如果这就是你要找的!还有祝你好运!

+0

g = sns.distplot(df ['MEDV'])与plt.ticklabel_format()有什么关系?我在其他地方看不到? –

+1

我相信它只是改变了所有matplotlib图的默认ticklabel格式。例如,如果您在代码的最开始处运行'plt.ticklabel_format(style ='sci',axis ='both',scilimits =(0,0)''''''',则它的工作方式是相同的。改变比图表改变。 – CalendarJ

2

你可以简单地划分系列100即

sns.distplot(df['MEDV']/100) 
plt.show() 

enter image description here 希望它可以帮助