Skip to content
Advertisement

mplFinance edit x-axis to show seconds

I am wondering if there is a way to have an MPLFinance plot show more keys(time) and seconds as well as minutes. I know you are able to add the minute, but can’t find anywhere to add the seconds.

Advertisement

Answer

You can tell mpf.plot() how you want to format the datetime axis using kwarg datetime_format=. You can use any valid strftime string.

For example, datetime_format='%b %d, %H:%M:%S' to show hours, minutes, and seconds (along with the month and day) for example, “Nov 3 14:53:15”. Of course, the datetime index of your DataFrame must contain hours, minutes, and seconds, or they may show as zeros: “Nov 3 00:00:00”.

Advertisement