Combining two different types of graphs in Holoviews using addition in Python

227 views Asked by At

I am trying to combine 2 different type of graph. Both the graphs have different x and y axis and that's how it should be. I have to send the plot in an combined way only. Below is what I tried and failed. Any workarounds?

import holoviews as hv
import pandas as pd

height_sub = 500
width_sub = 400

linechart1 = hv.Curve([(1,2,'crust'), (3,4,'moon'), (4,9, 'mars')])
bubbled1 = hv.Curve([(10,'blue'), (78,'pink')])

linechart1.opts(
    line_color='lightblue', 
#     size=10,
    width=width_sub,
    height=height_sub, 
#     color='lightblue',
#     show_grid=True
)

bubbled1.opts( 
    line_color='black', 
    size=5,
    width=width_sub,
    height=height_sub,
    color='blue',
#     show_grid=True
)
bubbled1 +linechart1

But caught up in error stack

~\.conda\envs\pyenv\lib\site-packages\holoviews\util\__init__.py in _options_error(cls, opt, objtype, backend, valid_options)
    415 
    416         if matches:
--> 417             raise ValueError('Unexpected option %r for %s type '
    418                              'across all extensions. Similar options '
    419                              'for current extension (%r) are: %s.' %

ValueError: Unexpected option 'size' for Curve type across all extensions. Similar options for current extension ('bokeh') are: ['fontsize'].

Is there any workaround possible?

1

There are 1 answers

5
Cameron Riddell On BEST ANSWER

size is not a style option for hv.Curve use line_width instead if you want thicker lines.

import holoviews as hv
hv.extension("bokeh")

height_sub = 500
width_sub = 400

linechart1 = hv.Curve([(1,2,'crust'), (3,4,'moon'), (4,9, 'mars')])
bubbled1 = hv.Curve([(10,'blue'), (78,'pink')])

linechart1.opts(
    line_color='lightblue', 
    line_width=10,
    width=width_sub,
    height=height_sub, 
    invert_axes=True
)

bubbled1.opts( 
    line_color='black', 
    line_width=5,
    width=width_sub,
    height=height_sub,
    color='blue',
)

layout = bubbled1 + linechart1
layout.opts(shared_axes=False)

enter image description here