![]() The “gender” and “survival” lists need to indicate to which category these values belong. The List will contain the count of “female”, non survivors and survivors, in this order, and then “male”, in the same order. Then, we need to transform the values in a Python List. Let’s use Pandas’ pivot_table to calculate that. We will need the quantity of survivors and non survivors for each gender. Additionally, we will create multiple charts, and then we can learn how to create both simple bar charts and stacked bar charts.įirst, let’s define the values we need. Let’s see the Titanic survival by gender example with Bokeh. Bar Chartsĭata for a Bar Chart in Bokeh is organized in Python Dictionaries, composed of Lists with the values to be used on the chart. Bar charts in Bokeh works a little differently. Nice, isn’t it? Now let’s create some bar charts. circle (ages, fare, size = 5, alpha = 0.5 ) Output_file ( "bokeh_scatter_example.html", title = "Bokeh Scatter Plot Example" )įig2 = figure (title = "Bokeh Scatter Plot Example", x_axis_label = 'Age' ,įig2. Let’s set an alpha value for transparency and the size of the points: ![]() ![]() Then, we will configure the output file and the figure, but now we will use the circle function from the figure to create the plot points. Like the first example, we will set the data that will be used for the plot, extracting them from the Titanic Dataset. Now, let’s see how we can create a scatter plot with Bokeh, like the one we created on the previous post. This interactivity is really nice when you want to create a web application that involves charts. Note that you can pan the chart, save, zoom in with the mouse scroll. line (x, y ) # Show results, similar to matplotlib Output_file ( "bokeh_example_1.html", title = "Bokeh Line Chart Example" ) # Create the figure and define some propertiesįig = figure (title = "Bokeh Line Chart Example", x_axis_label = 'x', y_axis_label = 'y' ) # Add the lineįig. X = range ( len (y ) ) # Configuring plot output file plotting import figure, output_file, show
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |