Plotting
Lines, histograms with per-bar colors, fills, hlines, and shape markers.
plot
plot(series, name, color?, linewidth?, plot_type?, opacity?, colors?, align?, width_px?)
Draw a data series on the chart.
Draws a line, histogram, area, or step line from a pandas Series. Each plot() call creates a named series visible in the chart legend.
For per-bar coloring (e.g. yellow for block trades, gray for normal), pass a colors= array the same length as series. Per-bar colors are only valid for HISTOGRAM, COLUMNS, CROSS, CIRCLES. Lines, areas, and step lines stay single-color.
align= reshapes the geometry instead of laying bars along the time axis:
pinned_top/pinned_bottom- horizontal strip glued to chart top/bottom (volume-pane layout). Bars time-align to candles viatimeToCoordinate; height proportional to value normalized to visible range.pinned_left/pinned_right- vertical strip glued to chart left/right edge (HUD layout). Anchored to the price axis.left_of_range/right_of_range- anchored to the first/last visible bar.over_range- stretches across the visible range.
Pair with width_px= to control the pinned strip width (left/right) or thickness (top/bottom).
Parameters
series(Series, defaultrequired): pandas Series of values to plotname(str, defaultrequired): Legend label (must be unique per indicator)color(str, default"#2962FF"): Hex color string (fallback whencolors[i]is None). Accepts 6-char#rrggbbor 8-char#rrggbbaa.linewidth(int, default2): Line thickness in pixelsplot_type(PlotType, defaultLINE):LINE,HISTOGRAM,COLUMNS,CROSS,CIRCLES,AREA, orSTEPLINEopacity(int, default100): Opacity 0-100 for area fillscolors(list[str | None], defaultNone): Per-bar color override array. Same length asseries. None entries fall back tocolor. HISTOGRAM/COLUMNS/CROSS/CIRCLES only.align(str, defaultNone):pinned_top,pinned_bottom,pinned_left,pinned_right,left_of_range,right_of_range, orover_range. HISTOGRAM/COLUMNS/AREA only.width_px(int, default60): CSS pixels for the pinned region. Strip width forpinned_left/pinned_right; strip thickness forpinned_top/pinned_bottom.
Returns
None
Example
sma = close.rolling(20).mean()
plot(sma, "SMA(20)", color="#2962FF", linewidth=2)
# Per-bar histogram coloring: yellow on big trades, gray otherwise
import numpy as np
big = volume > volume.rolling(50).mean() * 3
colors = np.where(big, "#e0af68", "#3a3a45").tolist()
plot(volume, "Volume", color="#3a3a45", plot_type=PlotType.HISTOGRAM, colors=colors)
Notes
colors=is the per-bar override. Pass a list of hex strings orNone(None falls back tocolor).- Convenience helpers:
plot_histogram_colored,plot_columns_colored,plot_cross_colored,plot_circles_colored. - Mismatched length between
colorsandseriesraisesValueError. plot()has nostyleorlinestyleparameter (this is not Pine Script). Useplot_typefor line shape;linestyleexists only onhline. Passingstyle=orlinestyle=toplot()raises aTypeError.
plot_histogram_colored
plot_histogram_colored(series, name, base_color, colors)
Histogram with per-bar color overrides.
Convenience wrapper for plot(..., plot_type=HISTOGRAM, colors=...). Same shape as the Rust plot_histogram_colored builder.
Parameters
series(Series, defaultrequired): Values to plotname(str, defaultrequired): Legend labelbase_color(str, defaultrequired): Fallback color for bars wherecolors[i]is Nonecolors(list[str | None], defaultrequired): Per-bar color overrides
Returns
None
Example
from quant_charts import plot_histogram_colored
colors = ["#e0af68" if x > thresh else None for x in trade_size]
plot_histogram_colored(trade_size, "Trade Size", "#3a3a45", colors)
hline
hline(value, name, color?, linewidth?, linestyle?)
Draw a horizontal reference line at a fixed value.
Draws a horizontal line at a constant Y-axis value. Common for overbought/oversold levels in oscillators.
Parameters
value(float, defaultrequired): Y-axis valuename(str, defaultrequired): Legend labelcolor(str, default"#787B86"): Hex color stringlinewidth(int, default1): Line thickness in pixelslinestyle(str, default"solid"):"solid","dashed", or"dotted"
Returns
None
Example
hline(70, "Overbought", color="#EF5350", linestyle="dashed")
hline(30, "Oversold", color="#26A69A", linestyle="dashed")
fill
fill(series1_name, series2_name, color?, opacity?)
Fill the area between two plotted series.
Fills the space between two previously plotted series. Both must have been drawn with plot() first, referenced by their name string.
Parameters
series1_name(str, defaultrequired): Name of the firstplot()seriesseries2_name(str, defaultrequired): Name of the secondplot()seriescolor(str, default"#2962FF"): Fill color as hex stringopacity(int, default10): Fill opacity 0-100
Returns
None
Example
plot(upper, "Upper", color="#2962FF")
plot(lower, "Lower", color="#2962FF")
fill("Upper", "Lower", color="#2962FF", opacity=10)
vp_visual
vp_visual(anchor_ts, end_ts, price_min, price_step, bins, poc_price, vah, val, ...)
Emit a horizontal volume profile histogram (POC + value area).
Pure-Python parity with the Rust push_vp_visual(...) builder. The renderer draws bars at each price row, an accent line at the Point of Control, and the Value Area High / Low as a translucent zone.
anchor_ts and end_ts are Unix milliseconds (the executor converts to seconds for Lightweight Charts). bins[i] is the volume in the price row starting at price_min + i * price_step. align defaults to right_of_range; pass pinned_right to glue to the chart edge regardless of pan.
Progressive trails (poc_trail, value_area_trail) draw a moving POC/VA line across each session anchor instead of a single static profile.
Parameters
anchor_ts(int, defaultrequired): Anchor timestamp (Unix ms). Where the histogram baseline starts.end_ts(int, defaultrequired): End timestamp (Unix ms).price_min(float, defaultrequired): Lower edge of the lowest bin.price_step(float, defaultrequired): Row height in price units. Must be > 0.bins(list[float], defaultrequired): Volume per row, length = number of rows.poc_price(float, defaultrequired): Point of Control (highest-volume row center).vah(float, defaultrequired): Value Area High.val(float, defaultrequired): Value Area Low.color(str, default"#7aa2f7"): Bar color (overridden per-bin bybin_colors[i]).poc_color(str, default"#e0af68"): POC accent line color.value_area_color(str, default"#73daca"): Value-area zone color.opacity(int, default60): Bar opacity 0-100.width_px(int, default80): Histogram width in CSS pixels.align(str, default"right_of_range"):right_of_range,left_of_range,over_range,pinned_right,pinned_left,pinned_top,pinned_bottom.style(str, default"bars"):bars,line, orarea.bin_colors(list[str | None], defaultNone): Per-row color override (same length asbins).hvn_levels(list[float], defaultNone): High-volume node prices (drawn as bright lines).lvn_levels(list[float], defaultNone): Low-volume node prices.poc_trail(list[dict], defaultNone): List of{ts: ms, price: float}for a moving POC line.value_area_trail(list[dict], defaultNone): List of{ts: ms, vah: float, val: float}for VA bands.draw_level_lines(bool, defaultTrue): Draw POC/VAH/VAL horizontal lines across the range.
Returns
None
Example
from quant_charts import vp_visual
import numpy as np
# bin all session ticks into 0.25 price rows
bins = np.histogram(typical, range=(lo, hi), bins=int((hi-lo)/0.25))[0]
poc_idx = int(np.argmax(bins))
poc_price = lo + (poc_idx + 0.5) * 0.25
vp_visual(
anchor_ts=int(ts[0]), end_ts=int(ts[-1]),
price_min=lo, price_step=0.25,
bins=bins.tolist(),
poc_price=poc_price, vah=poc_price + 4.0, val=poc_price - 4.0,
width_px=80, opacity=55,
align="right_of_range",
)
Notes
- Timestamps are Unix MILLISECONDS; the executor converts to seconds.
opacityis rejected if outside 0-100. NaN/Inf in any price field is rejected.alignvalidates against the five known values; unknown strings raise.- Calling
vp_visual()multiple times in one calculate() emits multiple histograms (one per anchor).