![]() ![]() In the circle plot, I tried to show a few additional parameters which we can use, such as fill_color - to fill the circle, fill_alpha - opacity of color, line_color - Border color for the circle, and size - radius of the circle. Here, In the above code, we have used three different renders - vbar, line, and circle. To Explore interactiveness, download the plot above in HTML Format from here.Ĭombining multiple plots with different renders: #Combining mutliple plots with different renders from otting import figure, show x = df.values y1 = df.values y2 = df.values 圓 = df.values p = figure(title="Multiple Plots", x_axis_label="X Values", y_axis_label="Y Values") p.vbar(x=x, top=y1, legend_label="y1", color="skyblue", width=0.5, bottom=0) p.line(x, y2, legend_label="y2", color="black", line_width=2) p.circle(x,圓,legend_label="圓",fill_color="red",fill_alpha=0.5,line_color="yellow",size=10) # show the results show(p) To visualize the plots and make them interactive, Bokeh provides a few tools, as shown in the above plot - Pan, Box Zoom, Wheel Zoom, Save, and Reset. The parameters which we passed are x, y - Data, Legened_label - representing the label for y data, line_width - width of the line plot. The line() method is used to create the line plot.We can add additional options such as title, x_axis_label and y_axis_label for figure(). The figure is created using the figure() method.In the above code, after importing the data. from otting import figure, show, output_notebook x = df.values y = df.values # create a new plot with a title and axis labels p = figure(title="Line Plot x VS y", x_axis_label="X Values", y_axis_label="Y Values") # add a line renderer with legend and line thickness p.line(x, y, legend_label="y", line_width=2) # show the results output_notebook() show(p) To show the figure, the show function is used, and output_notebook is used explicitly when we want to Visualize the plot in the notebook. We need to import figures from Bokeh to create the figure. Importing libraries from otting import figure, show, output_notebook Installing Bokeh using Python - pip install bokeh Let’s start creating a line plot using Bokeh Dataset used can be found here. For Data Scientists, who want to analyze data, Bokeh helps them by creating interactive plots, using which they can zoom in and pan the charts and realize the patterns.For web developers who use Python Django or Flask, as plots are exported into HTML Files, they can easily embed them in Web pages.Unlike other plotting libraries, Bokeh makes the plots interactive, and we can export the plots into HTML files as Bokeh renders data using Python and Javascript. Bokeh is a data visualization library in Python which provides interactive and sophisticated features for data scientists to analyze the data. on_change ( 'value', update_data ) # Set up layouts and add to document inputs = column ( text, offset, amplitude, phase, freq ) bokeh_app = pn. data = dict ( x = x, y = y ) for w in : w. on_change ( 'value', update_title ) def update_data ( attrname, old, new ): # Get the current slider values a = amplitude. pi ) freq = Slider ( title = "frequency", value = 1.0, start = 0.1, end = 5.1, step = 0.1 ) # Set up callbacks def update_title ( attrname, old, new ): plot. line ( 'x', 'y', source = source, line_width = 3, line_alpha = 0.6 ) # Set up widgets text = TextInput ( title = "title", value = 'my sine wave' ) offset = Slider ( title = "offset", value = 0.0, start =- 5.0, end = 5.0, step = 0.1 ) amplitude = Slider ( title = "amplitude", value = 1.0, start =- 5.0, end = 5.0, step = 0.1 ) phase = Slider ( title = "phase", value = 0.0, start = 0.0, end = 2 * np. sin ( x ) source = ColumnDataSource ( data = dict ( x = x, y = y )) # Set up plot plot = figure ( plot_height = 400, plot_width = 400, title = "my sine wave", tools = "crosshair,pan,reset,save,wheel_zoom", x_range =, y_range = ) plot. Bokeh ( p, theme = "dark_minimal" ) bokeh_paneįrom bokeh.layouts import column, row from bokeh.models import ColumnDataSource, Slider, TextInput # Set up data N = 200 x = np. wedge ( x = 0, y = 1, radius = 0.4, start_angle = cumsum ( 'angle', include_zero = True ), end_angle = cumsum ( 'angle' ), line_color = "white", fill_color = 'color', legend_field = 'country', source = data ) p. ![]() sum () * 2 * pi data = Category20c p = figure ( plot_height = 350, title = "Pie Chart", toolbar_location = None, tools = "hover", tooltips =, x_range = ( - 0.5, 1.0 )) r = p. From math import pi from bokeh.palettes import Category20c, Category20 from otting import figure from ansform import cumsum x = ) data = data / data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |