Path: blob/master/Data Visualization using Python/3.Data Visualization using Plotty.ipynb
3074 views
Plotly
is an open-source module of Python which is used for data visualization
supports various graphs like line charts, scatter plots, bar charts, histograms, area plot, etc
Plotly uses javascript behind the scenes and is used to make interactive plots where we can zoom in on the graph or add additional information like data on hover
Plotly does not come built-in with Python. To install it type the below command in the terminal.
Creating Line Chart
line dash parameter which is used to group the lines according to the dataframe column passed.
group and color the data according to the species.
Bar Chart
Customize Bars
color: Used to color the bars.
facet_row: Divides the graph into rows according to the data passed
facet_col: Divides the graph into columns according to the data passed
Scatter Plot
customizations for Scatter Chart
color: Color the points. symbol: Gives a symbol to each point according to the data passed. size: The size for each point.
Histogram
Customizations with Histogram
color: To color the bars
nbins: To set the number of bins
histnorm: Mode through which the bins are represented. Different values that can be passed using this argument are-
percent or probability: The output of histfunc for a given bin is divided by the sum of the output of histfunc for all bins.
density: The output of histfunc for a given bin is divided by the size of the bin.
probability density: The output of histfunc for a given bin is normalized such that it corresponds to the probability that a random
barmode: Can be either ‘group’, ‘overlay’ or ‘relative’.
group: Bars are stacked above zero for positive values and below zero for negative values
overlay: Bars are drawn on the top of each other
group: Bars are placed beside each other.
Pie Chart
Customizations to Donut Chart–
color_discrete_sequence: Strings defining valid CSS colors
opacity: Opacity for markers. The value should be between 0 and 1
hole: Creates a hole in between to make it a donut chart. The value should be between 0 and 1
BoxPlot
Adding interaction to the plot
A drop-down menu is a part of the menu button which is displayed on a screen all the time. Every menu button is associated with a Menu widget that can display the choices for that menu button when clicked on it. In plotly, there are 4 possible methods to modify the charts by using update menu method.
restyle: modify data or data attributes
relayout: modify layout attributes
update: modify data and layout attributes
animate: start or pause an animation