尝试绘制大熊猫数据框的方框图,但x轴列名似乎不清楚。
import matplotlib.pyplot as plt
pd.set_option('display.mpl_style', 'default')
fig, ax1 = plt.subplots()
%matplotlib inline
df.boxplot(column = ['avg_dist','avg_rating_by_driver','avg_rating_of_driver','avg_surge','surge_pct','trips_in_first_30_days','weekday_pct'])
以下是输出
如何解决此问题,以便x轴列显示清晰
答案 0 :(得分:2)
我认为你需要参数rot
:
cols = ['avg_dist','avg_rating_by_driver','avg_rating_of_driver',
'avg_surge','surge_pct','trips_in_first_30_days','weekday_pct']
df.boxplot(column=cols, rot=90)
样品:
np.random.seed(100)
cols = ['avg_dist','avg_rating_by_driver','avg_rating_of_driver',
'avg_surge','surge_pct','trips_in_first_30_days','weekday_pct']
df = pd.DataFrame(np.random.rand(10, 7), columns=cols)
df.boxplot(column=cols, rot=90)
答案 1 :(得分:2)