Plotly legend title

前端 未结 4 690
既然无缘
既然无缘 2021-01-07 18:02

I\'d like to be able to add a title to the legend, in the following code. However, looking at the docs, I don\'t think there is a method for this.

import plo         


        
4条回答
  •  滥情空心
    2021-01-07 18:49

    It is very easy to plotly with jupyter through wrapper cufflinks.

    install these dependencies:

    !pip install pandas cufflinks plotly
    

    create data frame from your data.

    import pandas as pd
    

    load data

    x=[1, 2, 3, 4, 5]
    y=[1, 2, 3, 4, 5]
    

    make second y list to y1

    x=[1, 2, 3, 4, 5]
    y1=[5, 4, 3, 2, 1]
    

    create dataframe from your data list

    data = pd.DataFrame({"x": x, "y": y, "y1": y1}).set_index("x")
    

    load cufflinks and its configuration

    import cufflinks as cf
    cf.set_config_file(offline=True) 
    

    plot dataframe

    data.iplot()
    

    You will x on axis, y, y1 on y axis. You can show and hide line clicking on legend from right side.

    References:

    • https://plotly.com/javascript/configuration-options/

提交回复
热议问题