파이썬/그래프 그리기

python(vscode)/holoviews/legend position/curve

gongdol 2024. 3. 27. 00:28
300x250

1. 예시 코드 

import pandas as pd
import holoviews as hv
from holoviews import opts
from bokeh.plotting import show
hv.extension('bokeh')

df = pd.DataFrame(dict(x=[1, 2], y1=[0, 1], y2=[1, 0], y3=[0.8, 0.8], y4=[0.2,0.2]))
curve1 = hv.Curve(df, 'x', 'y1', label='curve1').opts(ylabel='y')
curve2 = hv.Curve(df, 'x', 'y2', label='curve2').opts(ylabel='y')
curve3 = hv.Curve(df, 'x', 'y3', label='curve3').opts(ylabel='y')
curve4 = hv.Curve(df, 'x', 'y4', label='curve4').opts(ylabel='y')

cc12 = (curve1 * curve2)
cc34 = (curve3 * curve4)

hm = hv.HoloMap({'a':cc12, 'b':cc34})
hm.opts(opts.Overlay(legend_position='top_left'))
show(hv.render(hm))

 

2. 위치 옵션 

['inner', 'right',
 'bottom', 'top',
'left', 'best',
'top_right',
'top_left',
'bottom_left',
 'bottom_right'],
default='inner'

300x250