【发布时间】:2021-07-01 19:50:01
【问题描述】:
我有下图,正如您所见,由于 3x10^3、4x10^3 和 5x10^3 的科学记数法,y 轴刻度标签在 3000、4000 和 5000 处有重叠,尽管我是强制的我自己的刻度标签,我的问题是如何删除这些标签?
我尝试了plt.ticklabel_format(style='plain'),但这给出了错误:“AttributeError: This method only works with the ScalarFormatter.”
# multivariate plot of price by cut and color, for approx. 1 carat diamonds
myticks = [2300, 2600, 3000, 3300, 3600, 4000, 4300, 4600, 5000]
ytick_names = ['{}'.format(tick) for tick in myticks]
diamonds_sub = diamonds[diamonds['carat'].between(0.5, 1.5)]
plt.figure(figsize=(12,5))
sb.pointplot(data=diamonds_sub, x='color', y='price', hue='cut')
plt.yscale('log')
plt.yticks(myticks, ytick_names);
【问题讨论】:
标签: python matplotlib data-analysis