You are currently viewing Plotly Data Visualization with Python
data visualization with plotly and pandas

Plotly Data Visualization with Python

Data Visualization adds life to our Machine Learning Projects! The plotted data helps us to draw inferences, insight about data.

With the basic plotting libraries like Matplotlib and Seaborn we get various plots and an idea about the shape and distribution of the data.

But what if we have a huge data set with tens of thousands of rows; I have found that matplotlib and seaborn have limitations. The plots obtained do not represent the data well and we get are left guessing about other features.

To obtain a more realistic and holistic view of data we have one very useful open source library called PLOTLY.

Thanks to Plotly that tens of thousands of data can be easily and beautifully represented.

Let us take TIPS data set and use plotly to plot the graphs. Let us start!!

We import pandas for file processing and plotly for plotting the data

So, here:

  1. we load the data in an object called df
  2. we then plot a pie plot showing the value as tip and according to day.
  3. the color sequence is chosen as darkmint
  4. lastly fig,show will show the figure.

https://plotly.com/python/discrete-color/ Check out for more color sequences.

The Plot obtained after running the code. We see that on Saturdays we have maximum share of Tips 35.6% followed by Sunday and Thursday.

The pie plot shows the tips share received from males and females. Another interesting feature is hover this displays the arguments we have passed along with extra argument like e.g. here total_bill

Now lets explore scatter plots in Plotly!

Here the arguments passed are total bill and tip in x and y axis respectively. The color here is same as hue used in seaborn, so here color is smoker, and let us now see how it looks!

The cool part is the hover which gives plotly an edge over seaborn and matplotlib. Notice that when we scroll to any scatter the value over hover will also change and provide us with the data we need and want to showcase. It is very useful when one wants to give Presentations and make a lasting impact!

Experiment with different data sets and explore how Plotly works. You will love and enjoy working with data, I can bet!

There are a few videos on Plotly explaining various features that Plotly offers like animation, time frame, hover data, more interactive plots can be plotted with these tools. Below is the link for a project on Plotly exploring all the cool features. Check it out!

https://youtu.be/mu9Kpn23QVA

All the best . Below is the link for my YouTube Channel please like, and subscribe. Thanks for reading.

This Post Has 2 Comments

  1. Like!! I blog frequently and I really thank you for your content. The article has truly peaked my interest.

    1. priancaasharma

      HI,
      Thanks for the Acknowledgement!
      Kindly suggest a few more things you want to know to elevate your interests further. I will be happy to help.

Leave a Reply