Plotly for Data Visualization

steve@thoughtsociety.org Amateur Data Science, Course, General Leave a Comment

If you have been interested in or dabbling with learning data science, you no doubt have come across plot.ly charts and graphs on the web. Many articles on Medium and kernels on Kaggle use plotly to visualize data that you can interact with.  You can see by the live plot below that you can mouse over data points and you will be shown the actual numbers. 

The interactive chart below is actually a Dash application hosted on AWS/EC2 in an iFrame. The underlying charting is provided by plotly python api calls.

 

 

This is not all you will see.  Notice the controls in the upper right hand corner when you hover over that area of the chart.  

These controls signify that you are looking at a plotly chart which has a signature control set that you can suppress or enable in your code.  In this case, we have not suppressed it.

This next interactive graph allows you to select a number of stocks by ticker and after pressing ‘select’ it will go get the data for those stocks in the time frame you specified and plot them in a comparison chart just as Yahoo/finance allows you to do.

This chart is completely styled by CSS and organized in Div’s using inline HTML inside the python code.  Underlying the charting is the Plot.ly python library which has an extensive API of charting and graphing that surpasses Matplotlib and in many ways, Seaborn.  Alongside the charting functions is plotly.js which provides the live interaction you see in the static graphs. Dash takes this to another level by adding a Flask web server and react.js bindings to provide very fast and efficient callback capability for interactive controls which are completely customizable.

The reason for discussing Dash when I am outlining the plot.ly framework is that you can learn plot.ly’s API and essentially stop there. But if you plan to host interactive charts in the cloud , you will want to add Dash concepts to your path. It will not be a large lift to go from Plot.ly to Dash.

 

Leave a Reply

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