snapatac2.pl.render_plot#
- snapatac2.pl.render_plot(fig, width=600, height=400, interactive=True, show=True, out_file=None, scale=None)[source]#
Render, display, or save a Plotly figure.
Use this function to apply SnapATAC2 plotting output rules to an existing Plotly figure. Most users should call higher-level plotting functions, which call this helper internally.
Anti-Patterns#
Do NOT expect a figure object when
show=Trueorout_fileis set; the function returns a figure only forshow=Falseandout_file=None.Do NOT save static image formats without the Plotly image export backend installed. Use
.htmlfor a dependency-light interactive file.
- param fig:
Plotly figure to render.
- type fig:
plotly.graph_objects.Figure
- param width:
Width of the rendered plot in pixels.
- type width:
int
- param height:
Height of the rendered plot in pixels.
- type height:
int
- param interactive:
Whether to display an interactive Plotly figure when
show=True. IfFalse, return an IPython PNG image object for display.- type interactive:
bool
- param show:
Whether to display the figure immediately.
- type show:
bool
- param out_file:
Output path for saving the plot. Supported suffixes include
.svg,.pdf,.png, and.html.- type out_file:
str | None
- param scale:
Scale factor for static image export. Use values greater than 1 to increase resolution.
- type scale:
float | None
- returns:
Returns the Plotly figure when
show=Falseandout_file=None; returns an IPython image whenshow=Trueandinteractive=False; otherwise renders or saves the plot and returnsNone.- rtype:
plotly.graph_objects.Figure’ | None
Examples
>>> import plotly.graph_objects as go >>> import snapatac2 as snap >>> fig = go.Figure(go.Scatter(x=[0, 1, 2], y=[1, 3, 2])) >>> fig = snap.pl.render_plot(fig, width=500, height=300, show=False) >>> fig.update_layout(title="Rendered plot")