plot

The plot namespace provides chart plotting functionality. The namespace itself is callable — plot(...) records a value series for output. In PyneCore, plots are written to CSV output by default, but the mechanism can be extended. The plot.* constants control visual style and line appearance when used in compatible renderers.

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. In PyneCore, this writes the value to CSV by default.

ParameterTypeDefaultDescription
seriesany—The value to record each bar.
titlestr | NoneNoneLabel for the plot. Defaults to "Plot". Duplicate titles are suffixed.

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() in compatible renderers.

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.

Compatibility Notes

The following Pine Script plot namespace members are not available in PyneCore:

NameStatus
plot.linestyle_dashedNot available in PyneCore
plot.linestyle_dottedNot available in PyneCore
plot.linestyle_solidNot available in PyneCore

The plot() function accepts but silently ignores Pine Script visual parameters (color, linewidth, style, trackprice, etc.) for source-level compatibility. These have no effect in the current PyneCore output backend.