Constructor
new()
Create a candlestick plot with default settings.
Returns: CandlestickPlot
Defaults:
- Candle width
0.7 - Wick width
1.5 - Green/red/gray colors
- No volume panel
- No legend
Adding Candles
with_candle()
Append a candle in categorical mode.
Category label shown on the x-axis tick
Opening price
Highest price during the period
Lowest price during the period
Closing price
Self
The candle is placed at its insertion index. Use this when candles are evenly spaced (daily, weekly data).
with_candle_at()
Append a candle at an explicit numeric x position.
Numeric x position where the candle body is centered
Label text (not used for axis ticks in numeric mode)
Opening price
Highest price during the period
Lowest price during the period
Closing price
Self
The candle body is centred at x on a continuous numeric x-axis. Use this when candles are unevenly spaced — for example quarterly data where x is a fractional year.
Volume Panel
with_volume()
Attach volume values to existing candles.
Iterator of volume values. Matched to candles in insertion order. If there are fewer volume values than candles, the remaining candles receive no volume.
Self
The volume data is not rendered until with_volume_panel is also called.
with_volume_panel()
Enable the volume bar panel below the price chart.
Returns: Self
The panel occupies the bottom portion of the chart area (default 22%). Requires volume data attached via with_volume. Volume bars are colored to match their candle (green = up, red = down).
with_volume_ratio()
Set the fraction of the total chart height used by the volume panel.
Fraction in
[0.0, 1.0] (default: 0.22)Self
For example 0.30 gives the volume panel 30% of the chart height and leaves 70% for the price chart. Has no effect unless with_volume_panel is also called.
Styling
with_candle_width()
Set the candle body width as a fraction of the slot between candles.
Width in
[0.0, 1.0] (default: 0.7)Self
In categorical mode the slot width is 1.0 (one index unit), so 0.7 gives a body that fills 70% of the available space. In numeric mode (with_candle_at) this value is in data units — set it to be smaller than the spacing between candles.
with_wick_width()
Set the wick stroke width in pixels.
Stroke width in pixels (default: 1.5)
Self
with_color_up()
Set the fill color for bullish candles where close > open.
CSS color string (default:
"rgb(68,170,68)" — green)Self
with_color_down()
Set the fill color for bearish candles where close < open.
CSS color string (default:
"rgb(204,68,68)" — red)Self
with_color_doji()
Set the fill color for doji candles where close == open.
CSS color string (default:
"#888888" — gray)Self
A doji typically signals indecision in the market.
Legend
with_legend()
Add a legend label, causing a legend box to appear inside the plot area.
Legend label text
Self
Complete Example
Public Fields
All candles in insertion order
Candle body width as a fraction of the slot width between candles (default: 0.7; range 0.0–1.0)
Wick stroke width in pixels (default: 1.5)
Fill color for bullish candles (
close > open). Default: "rgb(68,170,68)" (green)Fill color for bearish candles (
close < open). Default: "rgb(204,68,68)" (red)Fill color for doji candles (
close == open). Default: "#888888" (gray)Whether to render the volume bar panel below the price chart
Fraction of the total chart height reserved for the volume panel (default: 0.22)
Optional legend entry label