The plot namespace provides chart plotting functionality. The namespace itself is callable — plot(...) records a value series for output. The values go to the plot CSV; the visual parameters (color, line width, style, …) are recorded as plot metadata and written to the opt-in visual output (pyne run --viz, ScriptRunner(viz_path=...)) for renderers to use.

Quick Example

from pynecore.lib import script, plot, close, ta

@script.indicator(title="SMA Plot Example", overlay=True)
def main():
    sma20: float = ta.sma(close, 20)
    plot(sma20, title="SMA 20")
    plot(close, title="Close")

Functions

plot()

Records a series value on every bar for output. The value is written to the plot CSV; the other parameters are recorded as the plot’s visual metadata.

ParameterTypeDefaultDescription
seriesany—The value to record each bar.
titlestr | NoneNoneLabel for the plot. Defaults to "Plot". Duplicate titles get a number appended.
colorcolor | NoneNonePlot color. A color that changes from bar to bar is recorded as a per-bar color channel.
linewidthint1Line width in pixels.
styleplot styleNoneOne of the plot.style_* constants; None means plot.style_line.
trackpriceboolFalseShow a horizontal price line at the last value.
histbasefloat0.0Reference level for style_histogram, style_columns and style_area.
offsetint0Horizontal shift of the plot, in bars.
joinboolFalseJoin style_circles / style_cross points with lines.
editableboolTrueWhether the plot style is editable in a settings dialog.
show_lastint | NoneNonePlot only the last show_last bars.
displaydisplayNoneWhere the plot is displayed (display.* constants); recorded as all when None.
formatstr | NoneNoneValue formatting (format.price, format.volume, …).
precisionint | NoneNoneNumber of decimal places for the plotted values.
force_overlayboolFalseDisplay the plot on the main chart pane.

Returns: Plot — a plot reference object.

Note: Plot declarations must execute unconditionally in the direct body of the module-level main() function, before any possible early return. Calls inside helpers, branches, loops, or conditional expressions raise a source-located SyntaxError during AST transformation, before the script runs. This rule also applies to plotshape, plotchar, plotarrow, plotcandle, plotbar, hline, fill, bgcolor, barcolor, and alertcondition.

To show a plot conditionally, keep the call unconditional and pass na when it should be hidden. The CSV retains its column and records NaN on those bars:

plot(close if bar_index >= 3 else na, title="Close Price")

Import aliases and single static function aliases are supported. Passing plot functions as callbacks or storing them in containers is rejected because their call scope cannot be verified. Plot references returned by plot() can still be stored and passed to fill().

p = plot(close, title="Close Price")

Constants

Style constants are passed to the style parameter of plot() and recorded in the visual output.

ConstantDescription
plot.style_areaArea fill style.
plot.style_areabrArea fill style with breaks on na values.
plot.style_circlesCircles at each bar.
plot.style_columnsVertical columns (bar chart style).
plot.style_crossCross markers at each bar.
plot.style_histogramHistogram bars relative to zero.
plot.style_lineContinuous line (default).
plot.style_linebrLine with breaks on na values.
plot.style_steplineStepped line.
plot.style_steplinebrStepped line with breaks on na values.
plot.style_stepline_diamondStepped line with diamond markers at each vertex.

Line style constants:

ConstantDescription
plot.linestyle_solidSolid line.
plot.linestyle_dashedDashed line.
plot.linestyle_dottedDotted line.

Compatibility Notes

All plot.style_* and plot.linestyle_* constants exist. plot() accepts a linestyle argument so that Pine sources using it run, but the line style is not recorded in the visual output yet; every other visual parameter in the table above is.

The CSV output holds only the plotted values. Visual parameters reach a renderer only through the visual output.