The script below imports the healthexp dataset from the Python seaborn module. Plotting Bokeh Plots using Pandas DataFramesĪ useful feature of the Bokeh library is that it allows you to plot data from a Pandas dataframes. When you run this script yourself, you can drag, zoom, and save the above plot using the controls displayed on the right-hand side of the plot. circle ( x, y, size = 5, color = 'red', legend_label = 'circle' ) f. line ( x, y, line_width = 2, color = "blue", legend_label = 'line' ) f. For example, clicking the line legend will hide the line plot, in the output of the following script.įinally, call the show() function on the figure object to display the chart.įrom otting import figure, output_notebook, show import numpy as np x = list ( range ( 11 )) y = output_notebook () f = figure ( plot_width = 400, plot_height = 400 ) f. Setting the legend.click_policy to hide allows you to hide legends by clicking on the legend values. You can then pass the line width, color, and the label for the legend to line_width, color, and legend_label attributes, respectively. Once this is done, you can plot any plot using this figure object.įor example, to make a line plot, use the line() function and pass it the x and y coordinates of your line. You can optionally pass the width and height of your plot here. Next, you need to create a figure object. Otherwise, the plot will be displayed in your default browser. If you want to display the chart inside a Python notebook, you must call the output_notebook() function. To plot a chart with Bokeh, you need to import a figure object, then import the output_notebook and show functions from the otting module. In a later section, we’ll explain how to plot charts with the Pandas-Bokeh library. This section will show how to make charts with the Python Bokeh library.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |