![]() The example below shows one of many ways to create and use a control in Bokeh.Ĭreate a new file named main.py and insert the following code: Before adding the controls, you should determine what these controls should do in your web browser environment. The steps in this section show you how to add controls to a Bokeh graph. A link to view more information about configuring the plot tools.A button that resets the plot to a default condition.A tool to save the current plot to disk.This button stays on even if you select another tool, so you can pan and zoom, for example. The wheel zoom uses the scroll wheel on the mouse to zoom into the area selected by the mouse cursor.The box zoom expands the area you select for better viewing.A panning tool that allows you to move the entire plot around as needed.The list below outlines each one in order from top to bottom: The right-hand column of the graph includes all of Bokeh’s default tools. ![]() For example, you can change the box zoom to a lasso tool, instead. Unlike other plotting applications, you can change the tools to meet your needs using the techniques found in the Bokeh user guide. Like other plotting applications, you get some interesting controls by default. The image below displays the graph that is rendered by the code above. Click a second time and the line comes back. When you click on one of the lines in the legend, that line disappears from view and its legend entry is grayed out. Next, the code creates an interactive legend. ![]() The font size is a 25 point version of the default font. In this case, the title should appear in the center of the display, located above the plot, in red letters with a yellow background. The code defines styles for the plot’s title. This function defines the characteristics of the plot as a whole, which includes the x and y axis labels, and the range of values for each axis. The plotting process begins with a call to the figure() function. To experiment with the same numbers in the code, call np.ed(1). The code generates a series of random numbers to be used for the visualizations. X_range =(0, 11 ), y_range =(0,10 )) = "First Example" = "center" _color = "red" _font_size = "25px" _fill_color = "yellow" plot.line (x, y1, color = "blue", legend_label = "First" ) plot.line (x, y2, color = "green", legend_label = "Second" ) = "bottom_right" _policy = "hide" show (plot ) This section shows you how to install Bokeh using Pip and Anaconda or Miniconda. ![]() Bokeh is a very low-level product where you specify precisely how you want things drawn. This reduces the effort needed to apply special effects and eases the addition of labels to pie charts. Matplotlib provides additional drawing flexibility that allows you to make modifications directly to various axes. Matplotlib lacks such an extensive glyph library. In addition, Bokeh has an extensive library of glyphs that can be added to your visualizations. When you use Bokeh, you find that it produces beautiful interactive graphics with less code than Matplotlib requires. However, given its age, Bokeh has a strong community. This may be because Bokeh has not been around as long as Matplotlib. This functionality is explored later in the guide.įrom a support perspective, Matplotlib enjoys far greater community support than Bokeh does. Bokeh can produce Jupyter Notebook output or send its output to a file. Matplotlib, on the other hand, provides Python visualizations that integrate well with Jupyter Notebook. If your focus is on website interactivity, then Bokeh is the better choice. While Bokeh and Matplotlib both help you plot data, these two libraries are different tools for different purposes. This guide introduces you to Bokeh with example code that creates line and bar graphs. Bokeh is an interactive visualization library that focuses on browser output.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |