<jupyter_start><jupyter_text>Basic scatterplot<jupyter_code>from bokeh.io import output_notebook, show
from bokeh.plotting import figure
# create a new plot with default tools, using figure
p = figure(plot_width=400, plot_height=400)

# add a circle renderer with a size, color, and alpha
p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=15, line_color="navy", fill_color="orange", fill_alpha=0.5)

show(p) # show the results<jupyter_output><empty_output><jupyter_text>Interactive visualization using sliders<jupyter_code>from bokeh.layouts import row, column
from bokeh.models import CustomJS, ColumnDataSource, Slider
import matplotlib.pyplot as plt
x = [x*0.005 for x in range(0, 201)]

output_notebook()

source = ColumnDataSource(data=dict(x=x, y=x))

plot = figure(plot_width=400, plot_height=400)
plot.scatter('x', 'y', source=source, line_width=3, line_alpha=0.6)

slider = Slider(start=0.1, end=6, value=1, step=.1, title="power")

update_curve = CustomJS(args=dict(source=source, slider=slider), code="""
    var data = source.get('data');
    var f = slider.value;
    x = data['x']
    y = data['y']
    for (i = 0; i < x.length; i++) {
        y[i] = Math.pow(x[i], f)
    }
    source.change.emit();
""")
slider.js_on_change('value', update_curve)


show(row(slider, plot))
#scatterplot using sliders
x = [x*0.005 for x in range(0, 21)]

output_notebook()

source = ColumnDataSource(data=dict(x=x, y=x))

plot = figure(plot_width=400, plot_height=400)
plot.scatter('x', 'y', source=source, line_width=3, line_alpha=0.6)

slider = Slider(start=0.1, end=6, value=1, step=.1, title="power")

update_curve = CustomJS(args=dict(source=source, slider=slider), code="""
    var data = source.get('data');
    var f = slider.value;
    x = data['x']
    y = data['y']
    for (i = 0; i < x.length; i++) {
        y[i] = Math.pow(x[i], f)
    }
    source.change.emit();
""")
slider.js_on_change('value', update_curve)

print source.data['y']

show(row(slider, plot))
#Making equivalent of diffusion 
Arr = np.random.rand(2,100)

source = ColumnDataSource(data=dict(x=Arr[0,], y=Arr[1,]))
plot = figure(plot_width=400, plot_height=400)
plot.scatter('x', 'y', source=source, line_width=3, line_alpha=0.6)

slider = Slider(start=1, end=8, value=1, step=1, title="Diffusion_steps")
slider2 = Slider(start=1, end=8, value=1, step=1, title="Anti_Diffusion_steps")

update_curve = CustomJS(args=dict(source=source, slider=slider), code="""
    var data = source.get('data');
    var f = slider.value;
    x = data['x']
    y = data['y']
    for (i = 0; i < x.length; i++) {
        x[i] = Math.pow(x[i], f)
        y[i] = Math.pow(y[i], f)
    }
    source.change.emit();
""")

update_curve2 = CustomJS(args=dict(source=source, slider=slider2), code="""
    var data = source.get('data');
    var f = slider.value;
    x = data['x']
    y = data['y']
    for (i = 0; i < x.length; i++) {
        x[i] = Math.pow(x[i], 1/f)
        y[i] = Math.pow(y[i], 1/f)
    }
    source.change.emit();
""")

slider.js_on_change('value', update_curve)
slider2.js_on_change('value', update_curve2)

show(row(column(slider,slider2), plot))

from bokeh.models import TapTool, CustomJS, ColumnDataSource

callback = CustomJS(code="alert('hello world')")
tap = TapTool(callback=callback)

p = figure(plot_width=600, plot_height=300, tools=[tap])

p.circle(x=[1, 2, 3, 4, 5], y=[2, 5, 8, 2, 7], size=20)

show(p)
from bokeh.models import ColumnDataSource, OpenURL, TapTool
from bokeh.plotting import figure, output_file, show

output_file("openurl.html")

p = figure(plot_width=400, plot_height=400,
           tools="tap", title="Click the Dots")

source = ColumnDataSource(data=dict(
    x=[1, 2, 3, 4, 5],
    y=[2, 5, 8, 2, 7],
    color=["navy", "orange", "olive", "firebrick", "gold"]
    ))

p.circle('x', 'y', color='color', size=20, source=source)

url = "http://www.colors.commutercreative.com/@color/"
taptool = p.select(type=TapTool)
taptool.callback = OpenURL(url=url)

show(p)
from bokeh.models import ColumnDataSource, TapTool, DataRange1d, Plot, LinearAxis, Grid, HoverTool
from bokeh.plotting import figure, output_file, show
from bokeh.models.glyphs import HBar


p = figure(plot_width=400, plot_height=400,
           tools="tap", title="Click the Dots")

source = ColumnDataSource(data=dict(
    x=[1, 2, 3, 4, 5],
    y=[2, 5, 8, 2, 7],
    color=["navy", "orange", "olive", "firebrick", "gold"]
    ))

p.circle('x', 'y', color='color', size=20, source=source)

source2 = ColumnDataSource(data=dict(
    x=[1,2],
    y=[1,2]))


callback = CustomJS(args=dict(source2=source2), code="""
    var data = source2.get('data');
    var geom = cb_data['geometries'];
    
    data['x'] = [geom[0].x+1,geom[0].x-1]
    data['y'] = [geom[0].y+1,geom[0].y-1]    
    
    source2.trigger('change'); 
""")


def callback2(source2 = source2):
    data = source2.get('data')
    geom = cb_obj.get('geometries')
    
    data['x'] = [geom['x']+1,geom['x']-1]
    data['y'] = [geom['y']+1,geom['y']-1]    
    
    source2.trigger('change')

taptool = p.select(type=TapTool)
taptool.callback = CustomJS.from_py_func(callback2); 

xdr = DataRange1d()
ydr = DataRange1d()




p2 = figure(plot_width=400, plot_height=400)

p2.vbar(x=source2.data['x'], width=0.5, bottom=0,
       top=source2.data['y'], color="firebrick")


#glyph = HBar(source2.data['x'], source2.data['y'], left=0, height=0.5, fill_color="#b3de69")

#p2.add_glyph(source2, glyph)



#p2.add_glyph(source, glyph)




show(row(p,p2))
update()

source = ColumnDataSource(data=dict(
    x=[1, 2, 3, 4, 5],
    y=[2, 5, 8, 2, 7],
    color=["navy", "orange", "olive", "firebrick", "gold"]
    ))
source2.data['x']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18892794376098418, 'fraction_numerical': 0.0383128295254833, 'mean_word_length': 4.477382098171319, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '4361', 'license': 'MIT', 'n_tokens_mistral': 2384, 'n_tokens_neox': 2233, 'n_words': 468, 'path': 'TestingBokeh/.ipynb_checkpoints/TryingBasicBokeh-checkpoint.ipynb', 'repo_name': 'yjzhang/uncurl_app', 'size': '5690'}