【发布时间】:2021-12-08 03:59:32
【问题描述】:
我用 Python 3.8.12 创建了一个新环境并安装了以下包:
-
matplotlib(3.4.3) -
pandas(1.3.3) -
scikit-learn(0.24.2)
我在 Jupyter 笔记本中运行代码。
我正在使用来自pandas.DataFrame.plot.scatter 文档中两个示例的代码:
第一个例子的输出
df = pd.DataFrame([[5.1, 3.5, 0], [4.9, 3.0, 0], [7.0, 3.2, 1],
[6.4, 3.2, 1], [5.9, 3.0, 2]],
columns=['length', 'width', 'species'])
ax1 = df.plot.scatter(x='length',
y='width',
c='DarkBlue')
确实与文档中的情节相匹配。
但是:第二个示例的输出
ax2 = df.plot.scatter(x='length',
y='width',
c='species',
colormap='viridis')
不与文档中的绘图匹配:X 轴标签和次要刻度标签未显示在绘图(底部)上。
我的阴谋
我试过ax2.set_xlabel("length")(这应该是必要的),它没有效果。
这是一个错误吗?有人可以尝试复制吗?
【问题讨论】: