Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_lodstart_constructor_plot():
model = Plot()
event = events.LODStart(model)
assert event._model_id == model.id
def _make_plot(dimensions="both"):
source = ColumnDataSource(dict(x=[1, 2], y=[1, 1]))
plot = Plot(plot_height=400, plot_width=400, x_range=Range1d(0, 1), y_range=Range1d(0, 1), min_border=0)
plot.add_glyph(source, Rect(x='x', y='y', width=0.9, height=0.9))
plot.add_tools(PanTool(dimensions=dimensions))
code = RECORD("xrstart", "p.x_range.start", final=False) + \
RECORD("xrend", "p.x_range.end", final=False) + \
RECORD("yrstart", "p.y_range.start", final=False) + \
RECORD("yrend", "p.y_range.end")
plot.add_tools(CustomAction(callback=CustomJS(args=dict(p=plot), code=code)))
plot.toolbar_sticky = False
return plot
def _make_plot(dimensions="both"):
source = ColumnDataSource(dict(x=[1, 2], y=[1, 1]))
plot = Plot(plot_height=400, plot_width=400, x_range=Range1d(0, 1), y_range=Range1d(0, 1), min_border=0)
plot.add_glyph(source, Rect(x='x', y='y', width=0.9, height=0.9))
plot.add_tools(WheelZoomTool(dimensions=dimensions))
code = RECORD("xrstart", "p.x_range.start", final=False) + \
RECORD("xrend", "p.x_range.end", final=False) + \
RECORD("yrstart", "p.y_range.start", final=False) + \
RECORD("yrend", "p.y_range.end")
plot.add_tools(CustomAction(callback=CustomJS(args=dict(p=plot), code=code)))
plot.toolbar_sticky = False
return plot
def test__check_compatible_scale_and_ranges_incompat_factor_scale_and_numeric_range():
plot = Plot(x_scale=CategoricalScale(), x_range=DataRange1d())
check = plot._check_compatible_scale_and_ranges()
assert check != []
def _make_plot(dimensions="both", num_objects=0):
source = ColumnDataSource(dict(x=[1, 2], y=[1, 1], width=[0.5, 0.5], height=[0.5, 0.5]))
plot = Plot(plot_height=400, plot_width=400, x_range=Range1d(0, 3), y_range=Range1d(0, 3), min_border=0)
renderer = plot.add_glyph(source, Rect(x='x', y='y', width='width', height='height'))
tool = BoxEditTool(dimensions=dimensions, num_objects=num_objects, renderers=[renderer])
plot.add_tools(tool)
plot.toolbar.active_multi = tool
code = RECORD("x", "source.data.x", final=False) + \
RECORD("y", "source.data.y", final=False) + \
RECORD("width", "source.data.width", final=False) + \
RECORD("height", "source.data.height")
plot.add_tools(CustomAction(callback=CustomJS(args=dict(source=source), code=code)))
plot.toolbar_sticky = False
return plot
for year in years:
fertility = fertility_df[year]
fertility.name = 'fertility'
life = life_expectancy_df[year]
life.name = 'life'
population = population_df_size[year]
population.name = 'population'
new_df = pd.concat([fertility, life, population, region_names], axis=1)
sources['_' + str(year)] = ColumnDataSource(new_df)
dictionary_of_sources = dict(zip([x for x in years], ['_%s' % x for x in years]))
js_source_array = str(dictionary_of_sources).replace("'", "")
xdr = Range1d(1, 9)
ydr = Range1d(20, 100)
plot = Plot(
x_range=xdr,
y_range=ydr,
title=Title(text=''),
plot_width=800,
plot_height=400,
outline_line_color=None,
toolbar_location=None,
min_border=20,
)
AXIS_FORMATS = dict(
minor_tick_in=None,
minor_tick_out=None,
major_tick_in=None,
major_label_text_font_size="10pt",
major_label_text_font_style="normal",
import numpy as np
from bokeh.io import curdoc, show
from bokeh.models import CircleX, ColumnDataSource, Grid, LinearAxis, Plot
N = 9
x = np.linspace(-2, 2, N)
y = x**2
sizes = np.linspace(10, 20, N)
source = ColumnDataSource(dict(x=x, y=y, sizes=sizes))
plot = Plot(
title=None, plot_width=300, plot_height=300,
min_border=0, toolbar_location=None)
glyph = CircleX(x="x", y="y", size="sizes", line_color="#dd1c77", fill_color=None)
plot.add_glyph(source, glyph)
xaxis = LinearAxis()
plot.add_layout(xaxis, 'below')
yaxis = LinearAxis()
plot.add_layout(yaxis, 'left')
plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))
curdoc().add_root(plot)
from bokeh.io import curdoc, show
from bokeh.models import ColumnDataSource, Grid, HexTile, LinearAxis, Plot
source = ColumnDataSource(dict(
q=[0, 0, -1, -1, 1, 1, 0],
r=[0, -1, 0, 1, -1, 0, 1],
)
)
plot = Plot(
title=None, plot_width=300, plot_height=300,
min_border=0, toolbar_location=None)
glyph = HexTile(q="q", r="r", size=1, fill_color="#fb9a99", line_color="white")
plot.add_glyph(source, glyph)
xaxis = LinearAxis()
plot.add_layout(xaxis, 'below')
yaxis = LinearAxis()
plot.add_layout(yaxis, 'left')
plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))
curdoc().add_root(plot)
p.x_range.start = -10
p.x_range.end = 10
p.y_range.start = -52
p.y_range.end = 10
reset_button = Button(label='Reset', button_type='success',width=100)
reset_button.on_click(reset)
###############################################################################
# plot particle and displacements #############################################
###############################################################################
t = Title(text='Total displacement of soil particles')
p = Plot(title=t,x_range=Range1d(start=-10,end=10),y_range=Range1d(start=-52,end=10),
plot_height = 928, plot_width = 800)
p.toolbar.logo=None
xaxis = LinearAxis()
xaxis.axis_label = 'x in [m]'
yaxis = LinearAxis()
yaxis.axis_label = 'z in [m]'
p.title.text_font_size = '15pt'
glyph_line = Line(x='x', y='y', line_color='black', line_width=2)
glyph_surface = Line(x='x', y='y', line_color='black', line_width=1)
glyph_Annulus_static = Annulus(x='x_coord',y='z_coord',outer_radius=.01,
fill_color='grey')
glyph_Annulus_moving = Annulus(x='x_coord',y='z_coord',outer_radius=.04,
fill_color='saddlebrown',line_alpha=0.7,
fill_alpha=0.7)