lightweight-charts-python icon indicating copy to clipboard operation
lightweight-charts-python copied to clipboard

horizontal_line in sub_chart is not displayed properly

Open mizaibear opened this issue 3 months ago • 1 comments

Question

os:windows 10 python version:3.13.7 package version:2.1

chart = JupyterChart(inner_width=1, inner_height=0.5) sub_chart = chart.create_subchart(width=1, height=0.5, sync=True) ... chart.horizontal_line(price=10) # it works fine in main chart. sub_chart.horizontal_line(price=0) # but not properly displayed in sub_chart.

Code example

import pandas as pd
from lightweight_charts import JupyterChart
df = pd.read_csv('ohlcv.csv')
df['rsi'] = df['close'].rolling(window=period).mean()
chart = JupyterChart(inner_width=1, inner_height=0.5)
sub_chart = chart.create_subchart(width=1, height=0.5, sync=True)
line = sub_chart.create_line('rsi')
chart.set(df)
line.set(df[['date','rsi']])

chart.horizontal_line(price=10) # it works fine in main chart.
sub_chart.horizontal_line(price=0) # but not properly displayed in sub_chart.

chart.load()

mizaibear avatar Sep 22 '25 03:09 mizaibear

@mizaibear see this comment: https://github.com/louisnw01/lightweight-charts-python/issues/391#issuecomment-2149893012

"Drawings are placed onto a series; so you'd need to do open_line.horizonal_line(...)"

dajul avatar Oct 19 '25 10:10 dajul