Search code examples
djangoplotlypython-3.6

spider graphic line in plotly.graph_objects


When I generate my chart, the line does not end, however, and I tried in many ways, but nothing worked for me.

what is in r, are some variables that I have declared with already defined values

fig = go.Figure()


fig.add_trace(go.Scatterpolar(
    name = "Ideal",
    r=[ ideal_Funciones_Responsabilidades, ideal_etapas_propias, ideal_Aspectos_Legales, ideal_Gestion_Ambiental, ideal_Gestion_de_Seguridad, 
    ideal_manejo_Informacion, hallado_Tecnicos, ideal_Humanos , ideal_transversales],
    theta=categories,

    #connectgaps=True,
    #line_color = 'darkviolet'   

    type= 'scatterpolar',
    mode = 'lines',


))

fig.add_trace(go.Scatterpolar(
    name = "Hallado",
    r=[ hallado_Funciones_Responsabilidades, hallado_etapas_propias, hallado_Aspectos_Legales, hallado_Gestion_Ambiental, hallado_Gestion_de_Seguridad, 
    hallado_manejo_Informacion, hallado_Tecnicos, hallado_Humanos, hallado_transversales],
    theta=categories,
    #mode = "markers",


    type= 'scatterpolar',
    mode = 'lines',
    #line_color = 'peru'




))




fig.update_layout(

    polar=dict(


        radialaxis=dict(

            #visible=True,
            range=[0, maximo_valor + 1]
        )

        ),
    #line_close=True,
    # showlegend=False
)

Image:

enter image description here

I will be attentive to your help with this topic.


Solution

  • You can close the line using go.Scatterpolar() by repeating the first element in both the list for r and theta at the end of the list.

    Say you declared:

    r_list=[ ideal_Funciones_Responsabilidades, ideal_etapas_propias, ideal_Aspectos_Legales, ideal_Gestion_Ambiental, ideal_Gestion_de_Seguridad, 
    ideal_manejo_Informacion, hallado_Tecnicos, ideal_Humanos , ideal_transversales]
    r_list.append(r_list[0])
    

    Then use

    r=r_list