Quadratic Docs
Ask or search…
K

Plotly

Build beautiful charts in Python with popular charting library Plotly.

Getting started

Plotly support in Quadratic is fully functioning, enabling the full Plotly experience you're familiar with. Create any of the supported Plotly chart types, style them, and display them straight to your Quadratic spreadsheet.
Building charts with Plotly is a simple series of steps:
  1. 1.
    Create your chart
  2. 2.
    Style your chart
  3. 3.
    Display the chart to the sheet
  4. 4.
    Resize & adjust
You can learn more about Plotly here: https://plotly.com/python/

Line charts

# install plotly
import micropip
await micropip.install('plotly')
# import library
import plotly.express as px
# create figure
fig = px.line(df, x='col1', y='col2', title="Power generation")
# display figure to the spreadsheet
fig.show()

Bar charts

# install plotly
import micropip
await micropip.install('plotly')
# bar chart using plotly express, can create with plotly graph objects as well
import plotly.express as px
# create figure with specified data, assumes dataframe df with column names col1 and col2
fig = px.bar(df, x=df['col1'], y=df['col2'])
# display figure to spreadsheet
fig.show()

Histograms

# install plotly
import micropip
await micropip.install('plotly')
# import Plotly
import plotly.express as px
# create figure
fig = px.histogram(df, x = 'output')
# display to sheet
fig.show()

Scatter plots

# install plotly
import micropip
await micropip.install('plotly')
# import plotly
import plotly.express as px
# create chart
fig = px.scatter(df, y="col1", x="col2", color="col3")
fig.update_traces(marker_size=10)
fig.update_layout(scattermode="group")
# display to sheet
fig.show()

Heatmaps

# install plotly
import micropip
await micropip.install('plotly')
# import library
import plotly.express as px
# assumes 2d array Z
fig = px.imshow(Z, text_auto=True)
# display chart
fig.show()

More chart types

For more chart types explore the Plotly docs: https://plotly.com/python/

Styling

For more styling for Plotly charts: https://plotly.com/python/styling-plotly-express/
# some chart styling options to assist getting started
fig.update_layout(
xaxis=dict(
showline=True,
showgrid=False,
showticklabels=True,
linecolor='rgb(204, 204, 204)',
linewidth=2,
ticks='outside',
tickfont=dict(
family='Arial',
size=12,
color='rgb(82, 82, 82)',
),
),
yaxis=dict(
showgrid=False,
zeroline=False,
showline=False,
showticklabels=True,
),
autosize=False,
showlegend=False,
plot_bgcolor='white',
title='Historical power usage by month (1985-2018)'
)

Chart controls

You can resize by dragging the edges of the chart.