1

Is there a way to remove the border line around a plot created with hvplot/bokeh?

import pandas as pd
import hvplot.pandas

df = pd.DataFrame({'x': [0, 1, 2, 3, 4, 5], 'y': [1, 1, 2, 2, 3, 4]})

df.hvplot.line(x='x', y='y')

This example results in the following plot, where I would like to remove the red marked line:

enter image description here

Any suggestions? Thank you!

25334
  • 25
  • 4

1 Answers1

4

Yes, add style and remove border

import pandas as pd
import hvplot.pandas

df = pd.DataFrame({'x': [0, 1, 2, 3, 4, 5], 'y': [1, 1, 2, 2, 3, 4]})

df.hvplot.line(x='x', y='y', style={'border': None})

Many other parmeters can be added

import pandas as pd
import hvplot.pandas

df = pd.DataFrame({'x': [0, 1, 2, 3, 4, 5], 'y': [1, 1, 2, 2, 3, 4]})

df.hvplot.line(x='x', y='y', style={
    'background_fill_color': 'white', 
    'border_fill_color': 'white', 
    'border_line_color': 'white', 
    'outline_line_alpha': 0
})

EDIT: If you get a warning you do not want to ignore

You have two options:

import pandas as pd
import hvplot.pandas

df = pd.DataFrame({'x': [0, 1, 2, 3, 4, 5], 'y': [1, 1, 2, 2, 3, 4]})

plot = df.hvplot.line(x='x', y='y', color='black').opts(
    bgcolor='white', 
    title='My Plot'
)

plot 

or

import pandas as pd
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource

df = pd.DataFrame({'x': [0, 1, 2, 3, 4, 5], 'y': [1, 1, 2, 2, 3, 4]})

source = ColumnDataSource(df)

p = figure(title='My Plot', plot_width=400, plot_height=300)
p.line('x', 'y', source=source, line_color='black', line_width=2)

p.outline_line_alpha = 0  # Remove border
p.grid.visible = False ) #remove grid
show(p)

or with the same solution I initialy provided:

import pandas as pd
import hvplot.pandas

df = pd.DataFrame({'x': [0, 1, 2, 3, 4, 5], 'y': [1, 1, 2, 2, 3, 4]})

df.hvplot.line(x='x', y='y').opts(
    line_width=2,
    line_color='black',
    bgcolor='white',
)