【问题标题】:Weird artefacts in a matplotlib bar plotmatplotlib 条形图中的奇怪伪影
【发布时间】:2017-01-25 02:56:32
【问题描述】:

我正在使用 pandas 绘图工具来绘制条形图:

spy_price_data.iloc[40:,1].plot(kind='bar')

条形数据绘制正确,但图中包含奇怪的伪影,以实际图形下方的附加水平条的形式出现:

这可能是什么问题?

【问题讨论】:

  • 以下命令的输出是什么:print(spy_price_data.shape)print(spy_price_data.index.dtype)
  • 那些大概是刻度标签,因为太多了,所以模糊不清。
  • print(spy_price_data.shape)-> (390, 8) , print(spy_price_data.index.dtype)->datetime64[ns]
  • 这些可能是刻度标签。令人惊讶的是,当我在与线图 (plot()) 相同的日期时间 x 轴上绘制同一数据框的其他列时,刻度标签会自动调整,以便仅显示每小时刻度。为什么两种绘图类型在同一个 x 轴上表现如此不同?

标签: python pandas matplotlib bar-chart


【解决方案1】:

“奇怪的人工制品”是您的标签。您甚至可以(几乎)在最后阅读它们:

最后一个值似乎是2018-08-19 20:00:00。 为了使情节更具可读性,请查看 ImportanceOfBeingErnest 对问题Matplotlib: How to increase space between tickmarks (or reduce number of tickmarks)?的回答

【讨论】:

    猜你喜欢
    • 2017-05-29
    • 1970-01-01
    • 2020-06-09
    • 1970-01-01
    • 2014-06-14
    • 2021-06-11
    • 2015-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多