The annotation y-position doesn't correspond to the position I set in the API call. Am I doing something wrong here?
The x-position is correct.
qf=cf.QuantFig(
df,
title=f'{symbol} - {date}',
name=symbol,
theme='pearl',
up_color='green',
down_color='red',
)
qf.add_annotations(
[
{
'x': idx_high,
'y': df.loc[idx_high]['high'],
'text': f'High: {df.loc[idx_high]["high"]}',
'showarrow':False,
'textangle': 0
},
{
'x': idx_low,
'y': df.loc[idx_low]['low'],
'text': f'Low: {df.loc[idx_low]["low"]}',
'showarrow':False,
'textangle': 0
},
]
)
f = qf.figure()
f.show()

I think the way
add_annotationsfunction fromcufflinksworks differently than theadd_annotationfunction in plotly. You could probably figure out the exact reason if you look into the cufflinks source for add_annotations.The first part of the code is reproducing a candlestick plot using some sample stocks data:
Then if I use the add_annotations method from cufflinks, I can reproduce the same issue as you: the y values of the annotations aren't correct.
But if I instead use the
add_annotationsmethod forf(which is a plotly graph object), then the annotations appear in the correct location: