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.
Asked
Active
Viewed 504 times
1 Answers
4
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".

Daniel Goldfarb
- 6,937
- 5
- 29
- 61
-
This was very helpful! However, I am also looking to plot more labels. Currently, the chart shows ~5 over an x minute period. I need more like 10 over the same x period. Any chance you know how to solve this as well? – Xobiwan Nov 04 '21 at 01:27
-
2@Xobiwan I'm actually working on an enhancement for that presently. Still it could be another month, or more likely two, because I'm working on other projects too. I'll see if I can find you a work-around sometime in the next day or two. If you don't mind setting `show_nontrading=True` for your plots, then it will be easier to implement a workaround. lmk. – Daniel Goldfarb Nov 04 '21 at 03:53
-
I apologize for the delay. I will go ahead and set `show_nontrading=True` for the time being. Looking forward to seeing your change. – Xobiwan Nov 08 '21 at 16:00