Black Lives Matter. Please consider donating to Black Girls Code today.

Weird text/annotation in graph

Hi, I’m using the following code to create a plot:

def create_time_series(df):
    return {
        'data': [go.Scatter(
            x=df['date'],
            y=df['data'],
            mode='lines+markers',
            showlegend=False
        )],
        'layout': {
            'title': '',
            'height': 300,
            'margin': {'l': 100, 'b': 30, 'r': 10, 't': 50},
            'annotations': [{
                'x': 0, 'y': 0.85, 'xanchor': 'left', 'yanchor': 'bottom',
                'xref': 'paper', 'yref': 'paper', 'showarrow': False,
                'align': 'left', 'bgcolor': 'rgba(255, 255, 255, 0.5)'
            }],
            'yaxis': {'type': 'linear', 'title': ''},
            'xaxis': {'showgrid': False, 'tickformat': '%Y-%m-%d', 'title': ''}
        }
    }

For some reason it creates a weird text/annotation and I don’t understand why:

Does anyone have any idea why it occurs?

Thanks

It’s because you did not give the text property of your Annotation example. If you add 'text':'hello' inside the definition of your annotation you will see the text ‘hello’. Please refer to https://plot.ly/python/text-and-annotations/#simple-annotation for more details about annotations.