Matplotlib timedelta集ylim

2024-09-28 20:48:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一系列的图表,在x轴上绘制不同的日期,在y轴上以分钟为单位绘制时间。 enter image description here 这些图都有一个不同的最大值,我想将ylim设置为相同的值。我尝试从pandas dataframe中选择max值,并使用ylim将其设置为max。这将显示错误消息:

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

我尝试手动将限制设置为7,因为这样可以保持与下面类似的视觉效果,但是我得到了: enter image description here

当y轴以timedelta为单位且以分钟为单位测量时,如何修改限制?在


Tags: theto消息dataframepandas错误图表时间
1条回答
网友
1楼 · 发布于 2024-09-28 20:48:17

注意第一个图左上角的1e11? 这意味着y轴按1e11缩放。在

手动将ylim设置为7e11将很可能获得所需的结果。在

然而,70000000000分钟是一段很长的时间!这可能表明计算中有问题。最好检查代码中的除法-也许你除以一些非常小的数字。这也可能是您发布错误消息的原因。在

相关问题 更多 >