I m currently trying to create a chart using the following code
economiaAcumulada = [300, 700, 1200]
economiaMensal = [300, 400, 800]
meses = [ Jan , Fev , Mar ]
OUTPUT_FORMAT = "png"
import plotly.graph_objects as go
import plotly.subplots as sp
import plotly.express as px
def CriarGraficoAnaliseEconomica(acumulada, mensal, labels):
fig = px.line(x=labels, y=acumulada, color=px.Constant("Economia Acumulada"),
labels=dict(x="Meses", y="Valor", color=""))
fig.add_bar(x=labels, y=mensal, name="Economia Mensal")
fig.update_layout(legend=dict(
yanchor="top",
y=0.99,
xanchor="left",
x=0.01,
))
Is there a way to format/change the legend from a Line chart to be a square like the Bar chart?
- I ve tried switching the symbol property to square , but it didn t work for me.
- I ve also tried creating a third chart(Bar chart) without values, and using the ShowLegend=True property to display the desired legend format but the selection by clicking, selects a hidden chart.