4.4 Introduction of Plotly

Plotly: -

  • Plotly is a powerful and interactive plotting library in Python.
  • Unlike Matplotlib, Plotly allows users to zoom, pan, hover, and interact with plots in real-time.
  • It can create a wide variety of plots: line, scatter, bar, pie, bubble, 3D plots, maps, and dashboards.

 

  • Plotly can be installed using pip: py -m pip install plotly
  • Modules of plotly are Plotly Express and Plotly Graph Objects.
  • Plotly Express is a python visualization library for creating interactive and beautiful visualizations. it is used to produce professional and easy plots.
  • Plotly Graph Objects are used to produce more complex plots than that of Plotly Express.


Key Features of Plotly: -

  • Interactive plots: Hover over points to see values, zoom into regions, or click legend items.
  • Web-friendly: Plots can be embedded in web apps (e.g., using Dash).
  • Multiple chart types: Supports advanced visualizations like 3D surfaces, choropleth maps, sunburst charts.
  • Integration with Pandas: Directly plot DataFrames with minimal effort.

 

Creating charts with plotly: -

  • Creating charts with plotly are:

  1. Line chart.
  2. Bar chart.
  3. Histograms
  4. Scatter plot.
  5. bubble plot.
  6. Pie charts.
  7. 3D Scatter plot plotly

 

1. Line chart: -

  • Line chart is one of the simple plots where a line is drawn to show relation between the x - axis and y – axis.
  • It can be created using the px.line( ) method with each data position is represented as a vertex after polyline mark in 2D space.

            Example: -


            Output: -

2. Bar chart: -

  • Bar chart is a pictorial representation of data that represents categorical data with rectangular bars with heights or lengths proportional to the values that they represent.
  • In other words, it is the pictorial representation of dataset. these data sets contain the numerical values of variables that represent the length or height.
  • Here  we use iris dataset.





            Example: -

            


            Output: -      


3. Histograms: -

 

            Example: -


            Output: -

4. Bubble plot: -

 

                Example: -



                Output: -


5. Pie charts.

 

                Example: -



                Output: -



6. 3D Scatter plot plotly

 

                Example: -



                Output: -












Popular posts from this blog

2.4 Arrays in c programming

2.1 Control statements in C programming (sequential & conditional)

3.9 Word processing