Exemplo n.º 1
0
with group(width=700, height=90, background=codeback, y=t.bottom+0.03):
    code(r"""
slide()
title('Tikz')
p = tikz(r\""" ....[TIKZ LINES].... \""")
t = text(r"\href{http://www.texample.net/tikz/examples/tutorial/}
{http://www.texample.net/tikz/examples/tutorial/}",
x="center", y=p.bottom+0.11)
    """, langage="python", width="300", x="1cm")



slide('Bokeh plot')
from bokeh.plotting import figure as bokfig
import numpy as np
p = bokfig(height=300, width=600)
x = np.linspace(0, 4*np.pi, 30  )
y = np.sin(x)
p.circle(x, y, legend="sin(x)")
figure(p, y=0.1, x="center")

with group(width=700, height=155, background=codeback, y="11cm"):
    code("""
slide()
title('Bokeh plot')
from bokeh.plotting import figure as bokfig
import numpy as np
p = bokfig(height=300, width=600)
x = np.linspace(0, 4*np.pi, 30  )
y = np.sin(x)
p.circle(x, y, legend="sin(x)")
Exemplo n.º 2
0
    
########################################################
#
#From Bokeh
#----------
#
#.. note::
#   No svg export available for now, check the
#   html file of the prensetation
#

with slide('A bokeh figure'):
    from bokeh.plotting import figure as bokfig

    p = bokfig(height=300, width=600)
    x = np.random.rand(100)
    y = np.random.rand(100)
    p.circle(x, y, legend="sin(x)")

    figure(p)

# Export the 3 slides of the presentation
save('./examples_html_outputs/figure.html')

########################################################
#
#HTML output
#===========
#
#.. raw:: html
Exemplo n.º 3
0
def make_presentation():
    import numpy as np
    from bokeh.plotting import figure as bokfig
    from bokeh.models import Legend, LinearAxis
    import os
    doc = document(cache=False, optimize=False)

    with slide():
        p = bokfig(sizing_mode='scale_both')
        p.circle([1, 2], [3, 4])
        figure(p)

    with slide('A bokeh figure (the one in the documentation)'):

        p = bokfig(height=300, width=600)
        x = np.random.rand(100)
        y = np.random.rand(100)
        p.circle(x, y, legend="sin(x)")

        figure(p)

    with slide('Test s1'):
        p = bokfig(height=300, width=600)
        x = np.linspace(0, 4 * np.pi, 30)
        y = np.sin(x)
        p.circle(x, y, legend="sin(x)")

        text('test')[:]
        figure(p)[1]

    with slide():
        p = bokfig(height=600, width=800)
        x = np.linspace(0, 4 * np.pi, 30)
        y = np.sin(x)
        p.circle(x, y, legend="sin(x)", size=10)

        figure(p)

    with slide('Big font'):
        p = bokfig(height=500, width=750)

        x = np.linspace(0, 4 * np.pi, 30)
        y = np.sin(x)
        p.circle(x, y, legend="sin(x)", size=8)
        # configure visual properties on a plot's title attribute
        p.title.text = "Title With Options"
        p.title.text_color = "orange"
        p.title.text_font_size = "2.5vw"

        p.xaxis.axis_label = 'Time'
        p.yaxis.axis_label = 'Value'
        p.xaxis.axis_label_text_font_size = "1.5vw"
        p.xaxis.major_label_text_font_size = "1vw"
        p.yaxis.axis_label_text_font_size = "1.5vw"
        p.yaxis.major_label_text_font_size = "1vw"

        figure(p)
        """
        p = bokfig(height=300, width=600)
        x = np.linspace(0, 4*np.pi, 30  )
        y = np.sin(x)
        p.circle(x, y, legend="sin(x)", color='red')
        """
        #figure(p)

    with slide():
        N = 4000
        x = np.random.random(size=N) * 100
        y = np.random.random(size=N) * 100
        radii = np.random.random(size=N) * 1.5
        colors = [
            "#%02x%02x%02x" % (int(r), int(g), 150)
            for r, g in zip(50 + 2 * x, 30 + 2 * y)
        ]

        TOOLS = "hover,crosshair,pan,wheel_zoom,zoom_in,zoom_out,box_zoom,undo,redo,reset,tap,save,box_select,poly_select,lasso_select,"

        p = bokfig(tools=TOOLS, output_backend="webgl")

        p.scatter(x,
                  y,
                  radius=radii,
                  fill_color=colors,
                  fill_alpha=0.6,
                  line_color=None)

        figure(p)

    return doc