Plotly
Plotly Plasma is a small opinionated enhancement for the Plotly for Python library
Install / Use
/learn @a0th/PlotlyREADME
Plotly Plasma
Plotly Plasma is a small opinionated enhancement for the Plotly for Python library. It patches the Plotly Figure object, adding new methods to handle somewhat frequent use cases that would normally take some boilerplate code to solve.
Simply pip install plotly-plasma, import plasma, and you are good to go!
- Multiple y-axes
- Year over year comparison
- Multiple colors in a single line
- Multiple lines with continuous colormap
- Facets
Multiple y-axes
When the values of the metrics are in very different scales, Plotly doesn't have a quick way to produce dual axes.
The default function will use the largest axis, and small variances will be barely noticeable.
px.line(data[["sinoid_0", "sinoid_9"]])
Plasma will let you easily do that with .dual, which will make the
first column the left axis and the second column the right axis.
px.line(data[["sinoid_0", "sinoid_9"]]).dual()
Year-over-year comparison
When comparing timeseries, it is useful to overlay the same period of different years.
fig = px.line(data, y="sinoid_0", color=data.index.year)
You can use .yoy to do that, as long as the x-axis is a datetime.
fig.yoy()
Multiple colors in a single line
By default, when you pass a column to the color parameter, it will
use one line for every color value. Sometimes, we want a single line to
have multiple colors, for example, to highlight a specific period.
def add_month_condition(df):
s = np.select(
[
data.index.month == 1,
data.index.month == 6,
],
["january", "june"],
default="rest of year",
)
return df.assign(month_condition=s)
fig = px.line(
data.pipe(add_month_condition),
y="sinoid_0",
color="month_condition",
)
fig
You can use .single_line to do that.
fig.single_line()
Multiple lines with continuous colormap
Still on the color topic, Plotly will use a discrete colormap by default, which is not always the best option.
fig = px.line(
tall_format,
x="day",
y="value",
color="senoid_average",
)
fig
You can use .continuous_color to fix that. You can also pass a
colorscale parameter to define the colormap, which can be any of the
Plotly colormaps.
fig.continuous_color('Tropic')
Facets
Default facets have a column_name=column_value labels for facets,
which I find almost always undesirable.
fig = px.line(
tall_format,
x="day",
y="value",
facet_row="variable",
facet_col="is_even",
facet_col_spacing=0.05,
)
fig
You can fix those with fix_facets_labels.
fig.fix_facet_labels()
You can also pass any keyworks that would be accepted by the annotation.update
fig.fix_facet_labels(
font_size=12,
font_family="Courier New",
bgcolor="lightgrey",
)
Related Skills
node-connect
347.6kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
108.4kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
108.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
347.6kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
