Basic Plotting Using Bokeh Python Pandas Library – Scatter, Line Visualizations

 

Bokeh is a powerful framework for data visualization in Python. Here I take a look at straightforward plotting and visualization using this powerful library.

Credit to PythonHow. You can check him out on Youtube

bokeh.models #It is a low level interface which involves a lot of work

bokeh.plotting # It is a middle level interface

bokeh.chart # It is a  high level interface

Lets try to create scatter plot

In [130]:

 

lets create a dataframe and add some values to it for our plot

In [131]:

 

lets add some values to the X and Y axis

In [132]:

 

lets store the scatterplot in a variable

In [133]:

 

we can save our file as html using the output_file method and we can also show our plot using the show method

In [134]:

 

In [135]:

 

In [ ]:

lets now plot using the bokeh.plotting interface

lets import the figure object from the plotting interface as that is the main object we will be using to plot. the idea is that you make an empty figure and you add objects to it

In [136]:

 

lets store the figure object in a variable. we can set the with and height of the figure or we can leave it blank to use defaut with
and height

In [137]:

 

you can also customise the plot

In [138]:

 

let’s use the circle method to plot our scatter plots. the circle method takes array of X and Y values. You can also set the size of the scatter circles

In [139]:

 

Out[139]:

You can use a list to determine the size each X,Y pair of plot

In [140]:

 

you can get a full HELP with the p variable by typing help(p)

In [141]:

 

lets plot some time series data

In [142]:

 

In [143]:

 

responsive = True enlarges the whole graph to cover the screen

In [ ]:

lets plot with a line graph

In [128]:

 

Out[128]:

lets save the file and also show it

In [129]:

 

 

Want more information like this?

Similar Posts

  • |

    Rank Sort Series DataFrames in Python Pandas Numpy

      In this quick notes, we will have a look at Rank and Sort in Series and DataFrames in Python In [1]:

      In [3]:

      Out[3]:

    In [4]:

      Out[4]:

    In [5]:

     

    Out[5]:

    In [6]:

      Out[6]:

    In [7]:

      In [8]:

      Out[8]:

    In [10]:

     …

  • |

    Python iloc, loc, ix Data Retrieving Selection Functions

      Pandas iloc, loc, and ix functions are very powerful ways to quickly select data from your dataframe. Today , we take a quick look at these 3 functions. Credits to Data School, you can check him out in Youtube  In [1]:

      In [2]:

      In [3]:

      Out[3]: City Colors Reported Shape Reported State…

  • |

    Association Of The Literacy Rate And Life Expectancy & Association Of The Literacy Rate And Income Per Person: The Case of Ghana

    Background of the Dataset CSV file Used:   In the GapMinder Codebook the Unique        Identifier = Country Hence in this program, my Unique Identifier = Ghana 1.      There are 3 chosen variables (columns) that are core to my chosen research question which is based on the country Ghana. These are a.       incomeperperson b.      lifeexpectancy…

  • Simple Python Logging Callling Reload to Help Save Logging to File

      In this notes, we are looking at a simple but yet useful and powerful logging in Python In [77]:

      In [78]:

      In [79]:

     

      Want more information like this?

  • Array Processing – Python Numpy – How to work with Arrays in Python

      Hi Guys, Thanks for all your emails. In this note, we will be looking at Array Processing in Python. This is part of lectures on Learning Python for Data Analysis and Visualization by Jose Portilla on Udemy. In [3]:

      In [4]:

      In [5]:

      In [6]:

      Out[6]:

    In [7]:

      Out[7]:

    In [8]:…

  • | |

    Running a Random Forest – Data Analysis and Intrepretation

    Overview My research work deals with Ghana, a country from the Gapminder dataset as has already been discussed from the beginning and progression through this course. The variables in my observation dataset are all quantitative. For the purposes of this assignment, I have binned my quantitative target variable, Life Expectancy (lifeexpectancy) into a 2-level binary categorical target variable. I have named…

Leave a Reply

Your email address will not be published. Required fields are marked *