<s> from __future__ import print_function <EOL> from numpy import pi , sin , cos , linspace , tan <EOL> from bokeh . util . browser import view <EOL> from bokeh . document import Document <EOL> from bokeh . embed import file_html <EOL> from bokeh . models . glyphs import Line <EOL> from bokeh . models import ( <EOL> Plot , DataRange1d , LinearAxis , ColumnDataSource , <EOL> PanTool , WheelZoomTool , GridPlot <EOL> ) <EOL> from bokeh . resources import INLINE <EOL> x = linspace ( - <NUM_LIT:2> * pi , <NUM_LIT:2> * pi , <NUM_LIT:1000> ) <EOL> source = ColumnDataSource ( data = dict ( <EOL> x = x , <EOL> y1 = sin ( x ) , <EOL> y2 = cos ( x ) , <EOL> y3 = tan ( x ) , <EOL> y4 = sin ( x ) * cos ( x ) , <EOL> ) <EOL> ) <EOL> def make_plot ( source , xname , yname , line_color , xdr = None , ydr = None ) : <EOL> """<STR_LIT>""" <EOL> if xdr is None : xdr = DataRange1d ( ) <EOL> if ydr is None : ydr = DataRange1d ( ) <EOL> plot = Plot ( x_range = xdr , y_range = ydr , min_border = <NUM_LIT:50> ) <EOL> plot . add_layout ( LinearAxis ( ) , '<STR_LIT>' ) <EOL> plot . add_layout ( LinearAxis ( ) , '<STR_LIT:left>' ) <EOL> plot . add_glyph ( source , Line ( x = xname , y = yname , line_color = line_color ) ) <EOL> plot . add_tools ( PanTool ( ) , WheelZoomTool ( ) ) <EOL> return plot <EOL> plot1 = make_plot ( source , "<STR_LIT:x>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> plot2 = make_plot ( source , "<STR_LIT:x>" , "<STR_LIT>" , "<STR_LIT>" , xdr = plot1 . x_range ) <EOL> plot3 = make_plot ( source , "<STR_LIT:x>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> plot4 = make_plot ( source , "<STR_LIT:x>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> grid = GridPlot ( children = [ [ plot1 , plot2 ] , [ plot3 , plot4 ] ] ) <EOL> doc = Document ( ) <EOL> doc . add_root ( grid ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> filename = "<STR_LIT>" <EOL> with open ( filename , "<STR_LIT:w>" ) as f : <EOL> f . write ( file_html ( doc , INLINE , "<STR_LIT>" ) ) <EOL> print ( "<STR_LIT>" % filename ) <EOL> view ( filename ) </s>
