How to create a new legend in plotly using go.layout?

How to add a new legend where for example i can state the red bar is prediction ?

For creating the legend this is my code

Hi @marconarca,
welcome to the community.

Can you please share your code with us as preFormatted text, instead of an image. In addition, if you can share the whole code so we can run it on our computer, that would be even better.

Lastly, can you please clarify what you’re trying to do with a new legend? Do you want to replace the default legend?

colors = [

    "orange",

    "orange",

    "orange",

    "orange",

    "orange",

    "orange",

    "orange",

    "red",

]

#colorbar=dict(bgcolor="#ff0000")

return {

    "data": [

        go.Bar(

            x=weekly_date,

            y=number_infected,

            name="Prediction Value",

            marker=dict(color=colors),

            hoverinfo="text",

            hovertext="<b>Date</b>: "

            + results[results["Barangay"] == zones_barangay]["Date"].astype(str)

            + "<br>"

            + "<b>Weekly Confirmed</b>: "

            + results[results["Barangay"] == zones_barangay]["Infection"].astype(

                str

            ),

        ),

        go.Scatter(

            x=results[results["Barangay"] == zones_barangay]["Date"],

            y=results[results["Barangay"] == zones_barangay]["Rolling Average"],

            mode="lines",

            name="Rolling average of the last four weeks - Weekly Infection Cases",

            line=dict(width=3, color="#FF00FF"),

            hoverinfo="text",

            hovertext="<b>Date</b>: "

            + results[results["Barangay"] == zones_barangay]["Date"].astype(str)

            + "<br>"

            + "<b>Rolling Ave. (last 4 weeks)</b>: "

            + results[results["Barangay"] == zones_barangay][

                "Rolling Average"

            ].astype(str)

            + "<br>"

            # marker=dict(

            #     color='green'),

        ),

    ],

    "layout": go.Layout(

        plot_bgcolor="#1f2c56",

        paper_bgcolor="#1f2c56",

        title={

            "text": "Predictive Confirmed Cases In : " + "Barangay Carmen",

            "y": 0.93,

            "x": 0.5,

            "xanchor": "center",

            "yanchor": "top",

        },

        titlefont={"color": "white", "size": 20},

        hovermode="x",

        margin=dict(r=0),

        xaxis=dict(

            title="<b>Date</b>",

            color="white",

            showline=True,

            showgrid=True,

            showticklabels=True,

            linecolor="white",

            linewidth=2,

            ticks="outside",

            tickfont=dict(family="Arial", size=12, color="white"),

        ),

        yaxis=dict(

            title="<b>Weekly Confirmed Cases</b>",

            color="white",

            showline=True,

            showgrid=True,

            showticklabels=True,

            linecolor="white",

            linewidth=2,

            ticks="outside",

            tickfont=dict(family="Arial", size=12, color="white"),

        ),

        legend={

            "orientation": "v",

            "bgcolor": "#1f2c56",

            "xanchor": "center",

            "x": 0.5,

            "y": -0.5,

        },

        font=dict(family="sans-serif", size=12, color="white"),

    ),

}

I just want the users of the app know that the red bar means is that it’s for the next week prediction