Cheat Sheet: Plotly and Dash

Cheat Sheet : Plotly and Dash

Function

Description

Syntax

Example

Plotly Express
scatterCreate a scatter plotpx.scatter(dataframe, x=x_column, y=y_column)px.scatter(df, x=age_array, y=income_array)
lineCreate a line plotpx.line( x=x_column, y=y_column,'title')px.line(x=months_array, y=no_bicycle_sold_array)
barCreate a bar plotpx.bar( x=x_column, y=y_column,title='title')px.bar( x=grade_array, y=score_array, title='Pass Percentage')
sunburstCreate a sunbust plotpx.sunburst(dataframe, path=[col1,col2..], values='column',title='title')px.sunburst(data, path=['Month', 'DestStateName'], values='Flights',title='Flight Distribution Hierarchy')
histogramCreate a histogrampx.histogram(x=x,title="title")px.histogram(x=heights_array,title="Distribution of Heights")
bubbleCreate a bubble chartpx.scatter(dataframe, x=x,y=y,size=size,title="title")px.scatter(bub_data, x="City", y="Numberofcrimes",
size="Numberofcrimes",hover_name="City", title='Crime Statistics')
pieCreate a pie chartpx.pie(values=x,names=y,title="title")px.pie(values=exp_percent,
names=house_holdcategories, title='Household Expenditure')
Plotly Graph Objects
ScatterCreate a scattergo.Scatter(x=x, y=y, mode='markers')go.Scatter(x=age_array, y=income_array, mode='markers')
Create a line plotgo.Scatter(x=x, y=y, mode='lines')go.Bar(x=months_array, y=no_bicycle_sold_array,mode='lines')
add_traceAdd additional traces to an existing figurefig.add_trace(trace_object)fig.add_trace(go.Scatter(x=months_array, y=no_bicycle_sold_array))
update_layoutUpdate the layout of a figure, such as title, axis labels, and annotations.fig.update_layout(layout_object)fig.update_layout(title='Bicycle Sales', xaxis_title='Months', yaxis_title='Number of Bicycles Sold')
Dash
dash_core_components.InputCreate an input componentdcc.Input(value='', type='text')dcc.Input(value='Hello', type='text')
dash_core_components.GraphCreate a graph componentdcc.Graph(figure=fig)dcc.Graph(figure=fig)
dash_html_components.DivCreate a div elementhtml.Div(children=component_list)html.Div(children=[html.H1('Hello Dash'), html.P('Welcome to Dash')])
dash_core_components.DropdownCreate a dropdown componentdcc.Dropdown(options=options_list, value=default_value)dcc.Dropdown(options=[{'label': 'Option 1', 'value': '1'}, {'label': 'Option 2', 'value': '2'}], value='1')

 

Comments

Popular posts from this blog

Common cybersecurity terminology

Introduction to security frameworks and controls

syllabus