Search code examples
pythonpython-3.xlistplotlygraphviz

Dot plot from list with Plotly


I have a Pandas Serie S, with

Index Number
A    10 
B    13
C    14
D    23

My target is to make a dot plot of this list with python.

I'm following this tuto : with plotly

However, I don't understand how to go from my serie to the viz.

I tried the following :

fig = px.scatter(s, x="number", y="index",
                 title="Title")

fig.show()

But nothing happens.

What is wrong in my process to go to the plotly dot plot ?


Solution

  • Similar to the tutorial you could save the data in a dataframe and plot it

    from bokeh.io import output_notebook
    output_notebook()
    import pandas as pd
    import plotly.express as px
    
    S = pd.Series([10, 13, 14, 23], index=['A','B','C','D'])
    df = pd.DataFrame({'index' : S.index,
                        'values': S.values})
    fig = px.scatter(df, x="index", y="values")
    fig.show()