• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Crypto Currency
  • Technology
  • Contact
NEO Share

NEO Share

Sharing The Latest Tech News

  • Home
  • Artificial Intelligence
  • Machine Learning
  • Computers
  • Mobile
  • Crypto Currency

Scatter Plot and Line Chart Dashboard in Plotly with Python

January 29, 2021 by systems

Visualization with Plotly

Amit Chauhan
Photo by Markus Winkler on Unsplash

To know the insights of the data we need wonderful visualization tools. Python is very useful programming to visualize data with pre-defined libraries in it. There are many useful visualization libraries like:

Among this matplotlib is a base library and others are built on top of it. Matplotlib idea comes from Matlab visuals plotting. It gives us static images. The matplotlib contains almost every plot.

Seaborn is designed to create an interactive statistical plot. It uses matplotlib as a backend. Visualization with seaborn in python is very simple and do plotting with less number of lines in python.

Plotly is an open-source library and creates interactive visualizations. Plotly not just has a library package in python but also in R, React, javascript and others.

The other thing we will see with plotly is the dash that is a very interactive plotting as a dashboard in web applications. Dash is an open-source library used for creating a fully functional dashboard.

To know more about the types of plots and chart can visit the site if plotly.

Extra Note: Power BI is a business intelligence tool that will help to analyze the data, clean the data, and converting that data into visual formats. PowerBI is developed by Microsoft Corporation with an initial release in 2014.

Scatter plot: It is used for correlation between two numerical variables and helps us to find insights and patterns from the graph. In the below figure we can see the types of correlation between two features.

Correlation relationship with different types of data. A photo from mathisfun

Let’s see a practical example of scatter and line chart with python.

For this, I used spyder IDE for the code in an anaconda distribution.

#import the necessary libraries
import numpy as np
import plotly.offline as pyo
import plotly.graph_objs as go

If plotly is not installed in your anaconda then install in the anaconda prompt by pip install plotly.

NumPy: NumPy is a python library package used for multidimensional array computing. NumPy process is faster than list because of its homogeneous type that is packed densely in memory and performed vectorization.

Plotly offline is used for creating a standalone HTML file and we can save it locally to see in our web browser.

Plotly graph_objs is used for importing all graphs objects in plotly.

# to generate the data with random number for x and  y axes
np.random.seed(42)
random_x = np.random.randint(1,101,100)
random_y = np.random.randint(1,101,100)

Random is used for getting random numbers with given range in the randint method.

data = [go.Scatter(x = random_x, y = random_y, mode = ‘markers’)]layout = go.Layout(title=’Hello First Plot’,
xaxis = dict(title=’My X axis’),
yaxis = dict(title=’My Y axis’),
hovermode = ‘closest’
)

Here, we select the scatter graph object in that we provided the input data and selected the mode as markers. The markers mean the dot point will be shown in the graph.

fig = go.Figure(data= data, layout = layout)
pyo.plot(fig, filename = ‘Scatter.html’)

The figure method is used to make the data and layout in proper graph format. The plot method is used to save the plot in an HTML file.

saved HTML file. A photo by Author

After opening the HTML file the plot will look like this as shown below.

Scatter Plot. A photo by Author

Line chart is a series of data connecting markers with line. The python code for this is shown below:

import numpy as np
import plotly.offline as pyo
import plotly.graph_objs as go
np.random.seed(50)
random_x = np.linspace(0,1,100)
random_y = np.random.randn(100)
data0 = go.Scatter(x = random_x, y = random_y, mode = 'markers', name='markers')data1 = go.Scatter(x = random_x, y = random_y+5, mode = 'lines', name='mylines')data = [data0, data1]layout = go.Layout(title='Line Chart')

fig = go.Figure(data= data, layout = layout)
pyo.plot(fig, filename = 'line_chart.html')

Line Chart in Plotly. A photo by Author

These are the basic plot visualization of plotly with python.

Conclusion:

The plotly is a great visualization tool embed with an HTML dashboard. Nowadays the demand for interactive visualization is on the boom because of the voluminous data flow in the world.

Reach me on my LinkedIn

  1. NLP — Zero to Hero with Python

2. Python Data Structures Data-types and Objects

3. MySQL: Zero to Hero

4. Basics of Time Series with Python

5. NumPy: Zero to Hero with Python

6. Fundamentals of series and Data Frame in Pandas with python

Filed Under: Machine Learning

Primary Sidebar

Stay Ahead: The Latest Tech News and Innovations

Cryptocurrency Market Updates: What’s Happening Now

Emerging Trends in Artificial Intelligence: What to Watch For

Top Cloud Computing Services to Secure Your Data

The Future of Mobile Technology: Recent Advancements and Predictions

Footer

  • Privacy Policy
  • Terms and Conditions

Copyright © 2025 NEO Share

Terms and Conditions - Privacy Policy