如何在pythonreportlab中格式化YvalueAxis标签

2024-09-27 20:18:21 发布

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

我正在用pythonreportlab创建一个垂直条形图。在

Y轴上的值是时间增量的倍(HH:MM:SS)。我必须将这些值转换为秒才能绘制图表。所以我得到了Y轴上的第二个值。在

如何根据HH:MM:SS格式格式化这些标签??在

如果这是不可能的,我怎么能隐藏这些标签?在


Tags: 格式hh图表时间绘制标签ss增量
1条回答
网友
1楼 · 发布于 2024-09-27 20:18:21

您可以为YValueAxis.labelTextFormat设置格式化程序函数。请参见documentation的YValueAxis部分:

This determines what goes in the labels. Unlike a category axis which accepts fixed strings, the labels on a ValueAxis are supposed to be numbers. You may provide either a 'format string' like '%0.2f' (show two decimal places), or an arbitrary function which accepts a number and returns a string. One use for the latter is to convert a timestamp to a readable year-month-day format.

相关问题 更多 >

    热门问题