我试图将多个条形图绘制为子图,但y轴一直在获取科学符号值。我运行的初始代码是:
from matplotlib import pyplot as plt
fig, axes = plt.subplots(7,3,figsize = (25, 40)) # axes is a numpy array of pyplot Axes
axes = iter(axes.ravel())
cat_columns=['Source','Side','State','Timezone',
'Amenity', 'Bump', 'Crossing', 'Give_Way',
'Junction', 'No_Exit', 'Railway', 'Roundabout', 'Station', 'Stop',
'Traffic_Calming', 'Traffic_Signal', 'Turning_Loop', 'Sunrise_Sunset',
'Civil_Twilight', 'Nautical_Twilight', 'Astronomical_Twilight']
for col in cat_columns:
ax = df[col].value_counts().plot(kind='bar',label = col, ax=axes.__next__())
输出如下所示:
fig, axes = plt.subplots(7,3,figsize = (25, 40)) # axes is a numpy array of pyplot Axes
axes = iter(axes.ravel())
cat_columns=['Source','Side','State','Timezone',
'Amenity', 'Bump', 'Crossing', 'Give_Way',
'Junction', 'No_Exit', 'Railway', 'Roundabout', 'Station', 'Stop',
'Traffic_Calming', 'Traffic_Signal', 'Turning_Loop', 'Sunrise_Sunset',
'Civil_Twilight', 'Nautical_Twilight', 'Astronomical_Twilight']
for col in cat_columns:
ax = df[col].value_counts().plot(kind='bar',label = col, ax=axes.__next__())
ax.ticklabel_format(useOffset=False, style='plain')
在使用这一行ax.ticklabel_格式(usecoffset=False,style='plain')之后,我得到了如下错误:
请告诉我这个错误
您可以通过创建自定义ScalarFormatter对象并关闭科学记数法来关闭此功能。有关更多详细信息,请参见matplotlib文档页面on tick formatters和on ^{}
相关问题 更多 >
编程相关推荐