You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code works, but the problem is that, instead of specifying the Y value with a number, i would like to specify it with dates, since my X axis has dates in the following format:
Date
2020-06-18 10:30:00
2020-06-18 10:35:00
2020-06-18 10:40:00
2020-06-18 10:45:00
I tried the following: new_patch = Rectangle(xy='2020-06-18 10:30:00',9300), width=4, height=0.3, angle=0, color='orange')
But that will give me an error since X is not int. I just moved to the new library from the older one, i really like all the new features, i'm just having some troubles drawing on the chart like i did with the older one! Any kind of help is appreciated!
The text was updated successfully, but these errors were encountered:
Hi @Dave-12-cr
There are a few things you can try. First, it is important to know that when show_nontrading=False (the default value) then the x-axis is simply the data point index number (from 0 up to N-1 where N is the number of rows in your dataframe).
You can try setting show_nontrading=True. This will cause the x-axis to be matplotlib dates. This may work, although you may have to convert '2020-06-18 10:30:00' into a matplotlib date first.
You can also try passing in the index number closest to the datetime you want. For example, if '2020-06-18 10:30:00' is on the 12th row of your dataframe, you would pass in 11.0 as the x-axis value (counting from zero to the 12th row). As another example, if '2020-06-18 10:30:00' represents a time that is halfway between the 16th row and the 17th row, then you would pass in 15.5 (thus interpolating the location).
Personally I recommend number 3 or number 4 above as possibly being the simplest to implement; but give whichever one you want a try and let me know how it turns out for you.
I created a candle chart with
fig, axlist = mpf.plot(df, type='candle', returnfig=True)
I'm trying to add on my chart a patch, here is what i tried:
This code works, but the problem is that, instead of specifying the Y value with a number, i would like to specify it with dates, since my X axis has dates in the following format:
I tried the following:
new_patch = Rectangle(xy='2020-06-18 10:30:00',9300), width=4, height=0.3, angle=0, color='orange')
But that will give me an error since X is not
int
. I just moved to the new library from the older one, i really like all the new features, i'm just having some troubles drawing on the chart like i did with the older one! Any kind of help is appreciated!The text was updated successfully, but these errors were encountered: