Plotly – Heatmap ”; Previous Next A heat map (or heatmap) is a graphical representation of data where the individual values contained in a matrix are represented as colors. The primary purpose of Heat Maps is to better visualize the volume of locations/events within a dataset and assist in directing viewers towards areas on data visualizations that matter most. Because of their reliance on color to communicate values, Heat Maps are perhaps most commonly used to display a more generalized view of numeric values. Heat Maps are extremely versatile and efficient in drawing attention to trends, and it’s for these reasons they have become increasingly popular within the analytics community. Heat Maps are innately self-explanatory. The darker the shade, the greater the quantity (the higher the value, the tighter the dispersion, etc.). Plotly’s graph_objects module contains Heatmap() function. It needs x, y and z attributes. Their value can be a list, numpy array or Pandas dataframe. In the following example, we have a 2D list or array which defines the data (harvest by different farmers in tons/year) to color code. We then also need two lists of names of farmers and vegetables cultivated by them. vegetables = [ “cucumber”, “tomato”, “lettuce”, “asparagus”, “potato”, “wheat”, “barley” ] farmers = [ “Farmer Joe”, “Upland Bros.”, “Smith Gardening”, “Agrifun”, “Organiculture”, “BioGoods Ltd.”, “Cornylee Corp.” ] harvest = np.array( [ [0.8, 2.4, 2.5, 3.9, 0.0, 4.0, 0.0], [2.4, 0.0, 4.0, 1.0, 2.7, 0.0, 0.0], [1.1, 2.4, 0.8, 4.3, 1.9, 4.4, 0.0], [0.6, 0.0, 0.3, 0.0, 3.1, 0.0, 0.0], [0.7, 1.7, 0.6, 2.6, 2.2, 6.2, 0.0], [1.3, 1.2, 0.0, 0.0, 0.0, 3.2, 5.1], [0.1, 2.0, 0.0, 1.4, 0.0, 1.9, 6.3] ] ) trace = go.Heatmap( x = vegetables, y = farmers, z = harvest, type = ”heatmap”, colorscale = ”Viridis” ) data = [trace] fig = go.Figure(data = data) iplot(fig) The output of the above mentioned code is given as follows − Print Page Previous Next Advertisements ”;
Category: plotly
Plotly – Distplots Density Plot and Error Bar Plot ”; Previous Next In this chapter, we will understand about distplots, density plot and error bar plot in detail. Let us begin by learning about distplots. Distplots The distplot figure factory displays a combination of statistical representations of numerical data, such as histogram, kernel density estimation or normal curve, and rug plot. The distplot can be composed of all or any combination of the following 3 components − histogram curve: (a) kernel density estimation or (b) normal curve, and rug plot The figure_factory module has create_distplot() function which needs a mandatory parameter called hist_data. Following code creates a basic distplot consisting of a histogram, a kde plot and a rug plot. x = np.random.randn(1000) hist_data = [x] group_labels = [”distplot”] fig = ff.create_distplot(hist_data, group_labels) iplot(fig) The output of the code mentioned above is as follows − Density Plot A density plot is a smoothed, continuous version of a histogram estimated from the data. The most common form of estimation is known as kernel density estimation (KDE). In this method, a continuous curve (the kernel) is drawn at every individual data point and all of these curves are then added together to make a single smooth density estimation. The create_2d_density() function in module plotly.figure_factory._2d_density returns a figure object for a 2D density plot. Following code is used to produce 2D Density plot over histogram data. t = np.linspace(-1, 1.2, 2000) x = (t**3) + (0.3 * np.random.randn(2000)) y = (t**6) + (0.3 * np.random.randn(2000)) fig = ff.create_2d_density( x, y) iplot(fig) Below mentioned is the output of the above given code. Error Bar Plot Error bars are graphical representations of the error or uncertainty in data, and they assist correct interpretation. For scientific purposes, reporting of errors is crucial in understanding the given data. Error bars are useful to problem solvers because error bars show the confidence or precision in a set of measurements or calculated values. Mostly error bars represent range and standard deviation of a dataset. They can help visualize how the data is spread around the mean value. Error bars can be generated on variety of plots such as bar plot, line plot, scatter plot etc. The go.Scatter() function has error_x and error_y properties that control how error bars are generated. visible (boolean) − Determines whether or not this set of error bars is visible. Type property has possible values “percent” | “constant” | “sqrt” | “data”. It sets the rule used to generate the error bars. If “percent”, the bar lengths correspond to a percentage of underlying data. Set this percentage in `value`. If “sqrt”, the bar lengths correspond to the square of the underlying data. If “data”, the bar lengths are set with data set `array`. symmetric property can be true or false. Accordingly, the error bars will have the same length in both direction or not (top/bottom for vertical bars, left/right for horizontal bars. array − sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data. arrayminus − Sets the data corresponding the length of each error bar in the bottom (left) direction for vertical (horizontal) bars Values are plotted relative to the underlying data. Following code displays symmetric error bars on a scatter plot − trace = go.Scatter( x = [0, 1, 2], y = [6, 10, 2], error_y = dict( type = ”data”, # value of error bar given in data coordinates array = [1, 2, 3], visible = True) ) data = [trace] layout = go.Layout(title = ”Symmetric Error Bar”) fig = go.Figure(data = data, layout = layout) iplot(fig) Given below is the output of the above stated code. Asymmetric error plot is rendered by following script − trace = go.Scatter( x = [1, 2, 3, 4], y =[ 2, 1, 3, 4], error_y = dict( type = ”data”, symmetric = False, array = [0.1, 0.2, 0.1, 0.1], arrayminus = [0.2, 0.4, 1, 0.2] ) ) data = [trace] layout = go.Layout(title = ”Asymmetric Error Bar”) fig = go.Figure(data = data, layout = layout) iplot(fig) The output of the same is as given below − Print Page Previous Next Advertisements ”;
Plotly – Polar Chart and Radar Chart ”; Previous Next In this chapter, we will learn how Polar Chart and Radar Chart can be made with the help Plotly. First of all, let us study about polar chart. Polar Chart Polar Chart is a common variation of circular graphs. It is useful when relationships between data points can be visualized most easily in terms of radiuses and angles. In Polar Charts, a series is represented by a closed curve that connect points in the polar coordinate system. Each data point is determined by the distance from the pole (the radial coordinate) and the angle from the fixed direction (the angular coordinate). A polar chart represents data along radial and angular axes. The radial and angular coordinates are given with the r and theta arguments for go.Scatterpolar() function. The theta data can be categorical, but, numerical data are possible too and is the most commonly used. Following code produces a basic polar chart. In addition to r and theta arguments, we set mode to lines (it can be set to markers well in which case only the data points will be displayed). import numpy as np r1 = [0,6,12,18,24,30,36,42,48,54,60] t1 = [1,0.995,0.978,0.951,0.914,0.866,0.809,0.743,0.669,0.588,0.5] trace = go.Scatterpolar( r = [0.5,1,2,2.5,3,4], theta = [35,70,120,155,205,240], mode = ”lines”, ) data = [trace] fig = go.Figure(data = data) iplot(fig) The output is given below − In the following example data from a comma-separated values (CSV) file is used to generate polar chart. First few rows of polar.csv are as follows − y,x1,x2,x3,x4,x5, 0,1,1,1,1,1, 6,0.995,0.997,0.996,0.998,0.997, 12,0.978,0.989,0.984,0.993,0.986, 18,0.951,0.976,0.963,0.985,0.969, 24,0.914,0.957,0.935,0.974,0.946, 30,0.866,0.933,0.9,0.96,0.916, 36,0.809,0.905,0.857,0.943,0.88, 42,0.743,0.872,0.807,0.923,0.838, 48,0.669,0.835,0.752,0.901,0.792, 54,0.588,0.794,0.691,0.876,0.74, 60,0.5,0.75,0.625,0.85,0.685, Enter the following script in notebook’s input cell to generate polar chart as below − import pandas as pd df = pd.read_csv(“polar.csv”) t1 = go.Scatterpolar( r = df[”x1”], theta = df[”y”], mode = ”lines”, name = ”t1” ) t2 = go.Scatterpolar( r = df[”x2”], theta = df[”y”], mode = ”lines”, name = ”t2” ) t3 = go.Scatterpolar( r = df[”x3”], theta = df[”y”], mode = ”lines”, name = ”t3” ) data = [t1,t2,t3] fig = go.Figure(data = data) iplot(fig) Given below is the output of the above mentioned code − Radar chart A Radar Chart (also known as a spider plot or star plot) displays multivariate data in the form of a two-dimensional chart of quantitative variables represented on axes originating from the center. The relative position and angle of the axes is typically uninformative. For a Radar Chart, use a polar chart with categorical angular variables in go.Scatterpolar() function in the general case. Following code renders a basic radar chart with Scatterpolar() function − radar = go.Scatterpolar( r = [1, 5, 2, 2, 3], theta = [ ”processing cost”, ”mechanical properties”, ”chemical stability”, ”thermal stability”, ”device integration” ], fill = ”toself” ) data = [radar] fig = go.Figure(data = data) iplot(fig) The below mentioned output is a result of the above given code − Print Page Previous Next Advertisements ”;
Plotly – Introduction
Plotly – Introduction ”; Previous Next Plotly is a Montreal based technical computing company involved in development of data analytics and visualisation tools such as Dash and Chart Studio. It has also developed open source graphing Application Programming Interface (API) libraries for Python, R, MATLAB, Javascript and other computer programming languages. Some of the important features of Plotly are as follows − It produces interactive graphs. The graphs are stored in JavaScript Object Notation (JSON) data format so that they can be read using scripts of other programming languages such as R, Julia, MATLAB etc. Graphs can be exported in various raster as well as vector image formats Print Page Previous Next Advertisements ”;
Plotly – Environment Setup
Plotly – Environment Setup ”; Previous Next This chapter focusses on how to do the environmental set up in Python with the help of Plotly. Installation of Python package It is always recommended to use Python’s virtual environment feature for installation of a new package. Following command creates a virtual environment in the specified folder. python -m myenv To activate the so created virtual environment run activate script in bin sub folder as shown below. source bin/activate Now we can install plotly’s Python package as given below using pip utility. pip install plotly You may also want to install Jupyter notebook app which is a web based interface to Ipython interpreter. pip install jupyter notebook Firstly, you need to create an account on website which is available at https://plot.ly. You can sign up by using the link mentioned herewith https://plot.ly/api_signup and then log in successfully. Next, obtain the API key from settings page of your dashboard. Use your username and API key to set up credentials on Python interpreter session. import plotly plotly.tools.set_credentials_file(username=”test”, api_key=”********************”) A special file named credentials is created in .plotly subfolder under your home directory. It looks similar to the following − { “username”: “test”, “api_key”: “********************”, “proxy_username”: “”, “proxy_password”: “”, “stream_ids”: [] } In order to generate plots, we need to import the following module from plotly package − import plotly.plotly as py import plotly.graph_objs as go plotly.plotly module contains the functions that will help us communicate with the Plotly servers. Functions in plotly.graph_objs module generates graph objects Print Page Previous Next Advertisements ”;
Plotly – Slider Control
Plotly – Slider Control ”; Previous Next Plotly has a convenient Slider that can be used to change the view of data/style of a plot by sliding a knob on the control which is placed at the bottom of rendered plot. Slider control is made up of different properties which are as follows − steps property is required for defining sliding positions of knob over the control. method property is having possible values as restyle | relayout | animate | update | skip, default is restyle. args property sets the arguments values to be passed to the Plotly method set in method on slide. We now deploy a simple slider control on a scatter plot which will vary the frequency of sine wave as the knob slides along the control. The slider is configured to have 50 steps. First add 50 traces of sine wave curve with incrementing frequency, all but 10th trace set to visible. Then, we configure each step with restyle method. For each step, all other step objects have visibility set to false. Finally, update Figure object’s layout by initializing sliders property. # Add traces, one for each slider step for step in np.arange(0, 5, 0.1): fig.add_trace( go.Scatter( visible = False, line = dict(color = “blue”, width = 2), name = “𝜈 = ” + str(step), x = np.arange(0, 10, 0.01), y = np.sin(step * np.arange(0, 10, 0.01)) ) ) fig.data[10].visible=True # Create and add slider steps = [] for i in range(len(fig.data)): step = dict( method = “restyle”, args = [“visible”, [False] * len(fig.data)], ) step[“args”][1][i] = True # Toggle i”th trace to “visible” steps.append(step) sliders = [dict(active = 10, steps = steps)] fig.layout.update(sliders=sliders) iplot(fig) To begin with, 10th sine wave trace will be visible. Try sliding the knob across the horizontal control at the bottom. You will see the frequency changing as shown below. Print Page Previous Next Advertisements ”;
Plotly – Format Axis & Ticks
Plotly – Format Axis and Ticks ”; Previous Next You can configure appearance of each axis by specifying the line width and color. It is also possible to define grid width and grid color. Let us learn about the same in detail in this chapter. Plot with Axis and Tick In the Layout object’s properties, setting showticklabels to true will enable ticks. The tickfont property is a dict object specifying font name, size, color, etc. The tickmode property can have two possible values — linear and array. If it is linear, the position of starting tick is determined by tick0 and step between ticks by dtick properties. If tickmode is set to array, you have to provide list of values and labels as tickval and ticktext properties. The Layout object also has Exponentformat attribute set to ‘e’ will cause tick values to be displayed in scientific notation. You also need to set showexponent property to ‘all’. We now format the Layout object in above example to configure x and y axis by specifying line, grid and title font properties and tick mode, values and font. layout = go.Layout( title = “Sine and cos”, xaxis = dict( title = ”angle”, showgrid = True, zeroline = True, showline = True, showticklabels = True, gridwidth = 1 ), yaxis = dict( showgrid = True, zeroline = True, showline = True, gridcolor = ”#bdbdbd”, gridwidth = 2, zerolinecolor = ”#969696”, zerolinewidth = 2, linecolor = ”#636363”, linewidth = 2, title = ”VALUE”, titlefont = dict( family = ”Arial, sans-serif”, size = 18, color = ”lightgrey” ), showticklabels = True, tickangle = 45, tickfont = dict( family = ”Old Standard TT, serif”, size = 14, color = ”black” ), tickmode = ”linear”, tick0 = 0.0, dtick = 0.25 ) ) Plot with Multiple Axes Sometimes it is useful to have dual x or y axes in a figure; for example, when plotting curves with different units together. Matplotlib supports this with the twinx and twiny functions. In the following example, the plot has dual y axes, one showing exp(x) and other showing log(x) x = np.arange(1,11) y1 = np.exp(x) y2 = np.log(x) trace1 = go.Scatter( x = x, y = y1, name = ”exp” ) trace2 = go.Scatter( x = x, y = y2, name = ”log”, yaxis = ”y2” ) data = [trace1, trace2] layout = go.Layout( title = ”Double Y Axis Example”, yaxis = dict( title = ”exp”,zeroline=True, showline = True ), yaxis2 = dict( title = ”log”, zeroline = True, showline = True, overlaying = ”y”, side = ”right” ) ) fig = go.Figure(data=data, layout=layout) iplot(fig) Here, additional y axis is configured as yaxis2 and appears on right side, having ‘log’ as title. Resultant plot is as follows − Print Page Previous Next Advertisements ”;
Plotly – Histogram
Plotly – Histogram ”; Previous Next Introduced by Karl Pearson, a histogram is an accurate representation of the distribution of numerical data which is an estimate of the probability distribution of a continuous variable (CORAL). It appears similar to bar graph, but, a bar graph relates two variables, whereas a histogram relates only one. A histogram requires bin (or bucket) which divides the entire range of values into a series of intervals—and then count how many values fall into each interval. The bins are usually specified as consecutive, non-overlapping intervals of a variable. The bins must be adjacent, and are often of equal size. A rectangle is erected over the bin with height proportional to the frequency—the number of cases in each bin. Histogram trace object is returned by go.Histogram() function. Its customization is done by various arguments or attributes. One essential argument is x or y set to a list, numpy array or Pandas dataframe object which is to be distributed in bins. By default, Plotly distributes the data points in automatically sized bins. However, you can define custom bin size. For that you need to set autobins to false, specify nbins (number of bins), its start and end values and size. Following code generates a simple histogram showing distribution of marks of students in a class inbins (sized automatically) − import numpy as np x1 = np.array([22,87,5,43,56,73,55,54,11,20,51,5,79,31,27]) data = [go.Histogram(x = x1)] fig = go.Figure(data) iplot(fig) The output is as shown below − The go.Histogram() function accepts histnorm, which specifies the type of normalization used for this histogram trace. Default is “”, the span of each bar corresponds to the number of occurrences (i.e. the number of data points lying inside the bins). If assigned “percent” / “probability”, the span of each bar corresponds to the percentage / fraction of occurrences with respect to the total number of sample points. If it is equal to “density“, the span of each bar corresponds to the number of occurrences in a bin divided by the size of the bin interval. There is also histfunc parameter whose default value is count. As a result, height of rectangle over a bin corresponds to count of data points. It can be set to sum, avg, min or max. The histogram() function can be set to display cumulative distribution of values in successive bins. For that, you need to set cumulative property to enabled. Result can be seen as below − data=[go.Histogram(x = x1, cumulative_enabled = True)] fig = go.Figure(data) iplot(fig) The output is as mentioned below − Print Page Previous Next Advertisements ”;
Plotly – Bar Chart and Pie Chart ”; Previous Next In this chapter, we will learn how to make bar and pie charts with the help of Plotly. Let us begin by understanding about bar chart. Bar Chart A bar chart presents categorical data with rectangular bars with heights or lengths proportional to the values that they represent. Bars can be displayed vertically or horizontally. It helps to show comparisons among discrete categories. One axis of the chart shows the specific categories being compared, and the other axis represents a measured value. Following example plots a simple bar chart about number of students enrolled for different courses. The go.Bar() function returns a bar trace with x coordinate set as list of subjects and y coordinate as number of students. import plotly.graph_objs as go langs = [”C”, ”C++”, ”Java”, ”Python”, ”PHP”] students = [23,17,35,29,12] data = [go.Bar( x = langs, y = students )] fig = go.Figure(data=data) iplot(fig) The output will be as shown below − To display a grouped bar chart, the barmode property of Layout object must be set to group. In the following code, multiple traces representing students in each year are plotted against subjects and shown as grouped bar chart. branches = [”CSE”, ”Mech”, ”Electronics”] fy = [23,17,35] sy = [20, 23, 30] ty = [30,20,15] trace1 = go.Bar( x = branches, y = fy, name = ”FY” ) trace2 = go.Bar( x = branches, y = sy, name = ”SY” ) trace3 = go.Bar( x = branches, y = ty, name = ”TY” ) data = [trace1, trace2, trace3] layout = go.Layout(barmode = ”group”) fig = go.Figure(data = data, layout = layout) iplot(fig) The output of the same is as follows − The barmode property determines how bars at the same location coordinate are displayed on the graph. Defined values are “stack” (bars stacked on top of one another), “relative”, (bars are stacked on top of one another, with negative values below the axis, positive values above), “group” (bars plotted next to one another). By changing barmode property to ‘stack’ the plotted graph appears as below − Pie chart A Pie Chart displays only one series of data. Pie Charts show the size of items (called wedge) in one data series, proportional to the sum of the items. Data points are shown as a percentage of the whole pie. The pie() function in graph_objs module – go.Pie(), returns a Pie trace. Two required arguments are labels and values. Let us plot a simple pie chart of language courses vs number of students as in the example given herewith. import plotly plotly.tools.set_credentials_file( username = ”lathkar”, api_key = ”U7vgRe1hqmRp4ZNf4PTN” ) from plotly.offline import iplot, init_notebook_mode init_notebook_mode(connected = True) import plotly.graph_objs as go langs = [”C”, ”C++”, ”Java”, ”Python”, ”PHP”] students = [23,17,35,29,12] trace = go.Pie(labels = langs, values = students) data = [trace] fig = go.Figure(data = data) iplot(fig) Following output is displayed in Jupyter notebook − Donut chart is a pie chart with a round hole in the center which makes it look like a donut. In the following example, two donut charts are displayed in 1X2 grid layout. While ‘label’ layout is same for both pie traces, row and column destination of each subplot is decided by domain property. For this purpose, we use the data of party-wise seats and vote share in 2019 parliamentary elections. Enter the following code in Jupyter notebook cell − parties = [”BJP”, ”CONGRESS”, ”DMK”, ”TMC”, ”YSRC”, ”SS”, ”JDU”,”BJD”, ”BSP”,”OTH”] seats = [303,52,23,22,22,18,16,12,10, 65] percent = [37.36, 19.49, 2.26, 4.07, 2.53, 2.10, 1.46, 1.66, 3.63, 25.44] import plotly.graph_objs as go data1 = { “values”: seats, “labels”: parties, “domain”: {“column”: 0}, “name”: “seats”, “hoverinfo”:”label+percent+name”, “hole”: .4, “type”: “pie” } data2 = { “values”: percent, “labels”: parties, “domain”: {“column”: 1}, “name”: “vote share”, “hoverinfo”:”label+percent+name”, “hole”: .4, “type”: “pie” } data = [data1,data2] layout = go.Layout( { “title”:”Parliamentary Election 2019″, “grid”: {“rows”: 1, “columns”: 2}, “annotations”: [ { “font”: { “size”: 20 }, “showarrow”: False, “text”: “seats”, “x”: 0.20, “y”: 0.5 }, { “font”: { “size”: 20 }, “showarrow”: False, “text”: “votes”, “x”: 0.8, “y”: 0.5 } ] } ) fig = go.Figure(data = data, layout = layout) iplot(fig) The output of the same is given below − Print Page Previous Next Advertisements ”;
Plotly – Dot Plots & Table
Plotly – Dot Plots and Table ”; Previous Next Here, we will learn about dot plots and table function in Plotly. Firstly, let us start with dot plots. Dot Plots A dot plot displays points on a very simple scale. It is only suitable for a small amount of data as a large number of points will make it look very cluttered. Dot plots are also known as Cleveland dot plots. They show changes between two (or more) points in time or between two (or more) conditions. Dot plots are similar to horizontal bar chart. However, they can be less cluttered and allow an easier comparison between conditions. The figure plots a scatter trace with mode attribute set to markers. Following example shows comparison of literacy rate amongst men and women as recorded in each census after independence of India. Two traces in the graph represent literacy percentage of men and women in each census after 1951 up to 2011. from plotly.offline import iplot, init_notebook_mode init_notebook_mode(connected = True) census = [1951,1961,1971,1981,1991,2001, 2011] x1 = [8.86, 15.35, 21.97, 29.76, 39.29, 53.67, 64.63] x2 = [27.15, 40.40, 45.96, 56.38,64.13, 75.26, 80.88] traceA = go.Scatter( x = x1, y = census, marker = dict(color = “crimson”, size = 12), mode = “markers”, name = “Women” ) traceB = go.Scatter( x = x2, y = census, marker = dict(color = “gold”, size = 12), mode = “markers”, name = “Men”) data = [traceA, traceB] layout = go.Layout( title = “Trend in Literacy rate in Post independent India”, xaxis_title = “percentage”, yaxis_title = “census” ) fig = go.Figure(data = data, layout = layout) iplot(fig) The output would be as shown below − Table in Plotly Plotly”s Table object is returned by go.Table() function. Table trace is a graph object useful for detailed data viewing in a grid of rows and columns. Table is using a column-major order, i.e. the grid is represented as a vector of column vectors. Two important parameters of go.Table() function are header which is the first row of table and cells which form rest of rows. Both parameters are dictionary objects. The values attribute of headers is a list of column headings, and a list of lists, each corresponding to one row. Further styling customization is done by linecolor, fill_color, font and other attributes. Following code displays the points table of round robin stage of recently concluded Cricket World Cup 2019. trace = go.Table( header = dict( values = [”Teams”,”Mat”,”Won”,”Lost”,”Tied”,”NR”,”Pts”,”NRR”], line_color = ”gray”, fill_color = ”lightskyblue”, align = ”left” ), cells = dict( values = [ [ ”India”, ”Australia”, ”England”, ”New Zealand”, ”Pakistan”, ”Sri Lanka”, ”South Africa”, ”Bangladesh”, ”West Indies”, ”Afghanistan” ], [9,9,9,9,9,9,9,9,9,9], [7,7,6,5,5,3,3,3,2,0], [1,2,3,3,3,4,5,5,6,9], [0,0,0,0,0,0,0,0,0,0], [1,0,0,1,1,2,1,1,1,0], [15,14,12,11,11,8,7,7,5,0], [0.809,0.868,1.152,0.175,-0.43,-0.919,-0.03,-0.41,-0.225,-1.322] ], line_color=”gray”, fill_color=”lightcyan”, align=”left” ) ) data = [trace] fig = go.Figure(data = data) iplot(fig) The output is as mentioned below − Table data can also be populated from Pandas dataframe. Let us create a comma separated file (points-table.csv) as below − Teams Mat Won Lost Tied NR Pts NRR India 9 7 1 0 1 15 0.809 Australia 9 7 2 0 0 14 0.868 England 9 6 3 0 0 14 1.152 New Zealand 9 5 3 0 1 11 0.175 Pakistan 9 5 3 0 1 11 -0.43 Sri Lanka 9 3 4 0 2 8 -0.919 South Africa 9 3 5 0 1 7 -0.03 Bangladesh 9 3 5 0 1 7 -0.41 Teams,Matches,Won,Lost,Tie,NR,Points,NRR India,9,7,1,0,1,15,0.809 Australia,9,7,2,0,0,14,0.868 England,9,6,3,0,0,12,1.152 New Zealand,9,5,3,0,1,11,0.175 Pakistan,9,5,3,0,1,11,-0.43 Sri Lanka,9,3,4,0,2,8,-0.919 South Africa,9,3,5,0,1,7,-0.03 Bangladesh,9,3,5,0,1,7,-0.41 West Indies,9,2,6,0,1,5,-0.225 Afghanistan,9,0,9,0,0,0,-1.322 We now construct a dataframe object from this csv file and use it to construct table trace as below − import pandas as pd df = pd.read_csv(”point-table.csv”) trace = go.Table( header = dict(values = list(df.columns)), cells = dict( values = [ df.Teams, df.Matches, df.Won, df.Lost, df.Tie, df.NR, df.Points, df.NRR ] ) ) data = [trace] fig = go.Figure(data = data) iplot(fig) Print Page Previous Next Advertisements ”;