Power BI – Useful Resources ”; Previous Next The following resources contain additional information on Power BI. Please use them to get more in-depth knowledge on this topic. Useful Video Courses Power BI Online Training Course Best Seller 41 Lectures 4 hours Tutorialspoint More Detail Mastering DAX And Data Models In Power BI Desktop 54 Lectures 5.5 hours Abhay Gadiya More Detail Microsoft Power BI Course by Tutorialspoint Best Seller 123 Lectures 7.5 hours Tutorialspoint More Detail Business Intelligence Course With Microsoft Power BI Best Seller 137 Lectures 8.5 hours Pavan Lalwani More Detail Data Science Bootcamp with Power BI and Python Best Seller 52 Lectures 3.5 hours Harshit Srivastava More Detail Print Page Previous Next Advertisements ”;
Category: Big Data & Analytics
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 ”;
Plotly – Box Plot Violin Plot and Contour Plot ”; Previous Next This chapter focusses on detail understanding about various plots including box plot, violin plot, contour plot and quiver plot. Initially, we will begin with the Box Plot follow. Box Plot A box plot displays a summary of a set of data containing the minimum, first quartile, median, third quartile, and maximum. In a box plot, we draw a box from the first quartile to the third quartile. A vertical line goes through the box at the median. The lines extending vertically from the boxes indicating variability outside the upper and lower quartiles are called whiskers. Hence, box plot is also known as box and whisker plot. The whiskers go from each quartile to the minimum or maximum. To draw Box chart, we have to use go.Box() function. The data series can be assigned to x or y parameter. Accordingly, the box plot will be drawn horizontally or vertically. In following example, sales figures of a certain company in its various branches is converted in horizontal box plot. It shows the median of minimum and maximum value. trace1 = go.Box(y = [1140,1460,489,594,502,508,370,200]) data = [trace1] fig = go.Figure(data) iplot(fig) The output of the same will be as follows − The go.Box() function can be given various other parameters to control the appearance and behaviour of box plot. One such is boxmean parameter. The boxmean parameter is set to true by default. As a result, the mean of the boxes” underlying distribution is drawn as a dashed line inside the boxes. If it is set to sd, the standard deviation of the distribution is also drawn. The boxpoints parameter is by default equal to “outliers“. Only the sample points lying outside the whiskers are shown. If “suspectedoutliers”, the outlier points are shown and points either less than 4″Q1-3″Q3 or greater than 4″Q3-3″Q1 are highlighted. If “False”, only the box(es) are shown with no sample points. In the following example, the box trace is drawn with standard deviation and outlier points. trc = go.Box( y = [ 0.75, 5.25, 5.5, 6, 6.2, 6.6, 6.80, 7.0, 7.2, 7.5, 7.5, 7.75, 8.15, 8.15, 8.65, 8.93, 9.2, 9.5, 10, 10.25, 11.5, 12, 16, 20.90, 22.3, 23.25 ], boxpoints = ”suspectedoutliers”, boxmean = ”sd” ) data = [trc] fig = go.Figure(data) iplot(fig) The output of the same is stated below − Violin Plot Violin plots are similar to box plots, except that they also show the probability density of the data at different values. Violin plots will include a marker for the median of the data and a box indicating the interquartile range, as in standard box plots. Overlaid on this box plot is a kernel density estimation. Like box plots, violin plots are used to represent comparison of a variable distribution (or sample distribution) across different “categories”. A violin plot is more informative than a plain box plot. In fact, while a box plot only shows summary statistics such as mean/median and interquartile ranges, the violin plot shows the full distribution of the data. Violin trace object is returned by go.Violin() function in graph_objects module. In order to display underlying box plot, the boxplot_visible attribute is set to True. Similarly, by setting meanline_visible property to true, a line corresponding to the sample”s mean is shown inside the violins. Following example demonstrates how Violin plot is displayed using plotly’s functionality. import numpy as np np.random.seed(10) c1 = np.random.normal(100, 10, 200) c2 = np.random.normal(80, 30, 200) trace1 = go.Violin(y = c1, meanline_visible = True) trace2 = go.Violin(y = c2, box_visible = True) data = [trace1, trace2] fig = go.Figure(data = data) iplot(fig) The output is as follows − Contour plot A 2D contour plot shows the contour lines of a 2D numerical array z, i.e. interpolated lines of isovalues of z. A contour line of a function of two variables is a curve along which the function has a constant value, so that the curve joins points of equal value. A contour plot is appropriate if you want to see how some value Z changes as a function of two inputs, X and Y such that Z = f(X,Y). A contour line or isoline of a function of two variables is a curve along which the function has a constant value. The independent variables x and y are usually restricted to a regular grid called meshgrid. The numpy.meshgrid creates a rectangular grid out of an array of x values and an array of y values. Let us first create data values for x, y and z using linspace() function from Numpy library. We create a meshgrid from x and y values and obtain z array consisting of square root of x2+y2 We have go.Contour() function in graph_objects module which takes x,y and z attributes. Following code snippet displays contour plot of x, y and z values computed as above. import numpy as np xlist = np.linspace(-3.0, 3.0, 100) ylist = np.linspace(-3.0, 3.0, 100) X, Y = np.meshgrid(xlist, ylist) Z = np.sqrt(X**2 + Y**2) trace = go.Contour(x = xlist, y = ylist, z = Z) data = [trace] fig = go.Figure(data) iplot(fig) The output is as follows − The contour plot can be customized by one or more of following parameters − Transpose (boolean) − Transposes the z data. If xtype (or ytype) equals “array”, x/y coordinates are given by “x”/”y”. If “scaled”, x coordinates are given by “x0” and “dx“. The connectgaps parameter determines whether or not gaps in the z data are filled in. Default value of ncontours parameter is 15. The actual number of contours will be chosen automatically to be less than or equal to the value of `ncontours`. Has an effect only
Plotly – Legends
Plotly – Legends ”; Previous Next By default, Plotly chart with multiple traces shows legends automatically. If it has only one trace, it is not displayed automatically. To display, set showlegend parameter of Layout object to True. layout = go.Layoyt(showlegend = True) Default labels of legends are trace object names. To set legend label explicitly set name property of trace. In following example, two scatter traces with name property are plotted. import numpy as np import math #needed for definition of pi xpoints = np.arange(0, math.pi*2, 0.05) y1 = np.sin(xpoints) y2 = np.cos(xpoints) trace0 = go.Scatter( x = xpoints, y = y1, name=”Sine” ) trace1 = go.Scatter( x = xpoints, y = y2, name = ”cos” ) data = [trace0, trace1] layout = go.Layout(title = “Sine and cos”, xaxis = {”title”:”angle”}, yaxis = {”title”:”value”}) fig = go.Figure(data = data, layout = layout) iplot(fig) The plot appears as below − Print Page Previous Next Advertisements ”;
Scatter Plot, Scattergl Plot and Bubble Charts ”; Previous Next This chapter emphasizes on details about Scatter Plot, Scattergl Plot and Bubble Charts. First, let us study about Scatter Plot. Scatter Plot Scatter plots are used to plot data points on a horizontal and a vertical axis to show how one variable affects another. Each row in the data table is represented by a marker whose position depends on its values in the columns set on the X and Y axes. The scatter() method of graph_objs module (go.Scatter) produces a scatter trace. Here, the mode property decides the appearance of data points. Default value of mode is lines which displays a continuous line connecting data points. If set to markers, only the data points represented by small filled circles are displayed. When mode is assigned ‘lines+markers’, both circles and lines are displayed. In the following example, plots scatter traces of three sets of randomly generated points in Cartesian coordinate system. Each trace displayed with different mode property is explained below. import numpy as np N = 100 x_vals = np.linspace(0, 1, N) y1 = np.random.randn(N) + 5 y2 = np.random.randn(N) y3 = np.random.randn(N) – 5 trace0 = go.Scatter( x = x_vals, y = y1, mode = ”markers”, name = ”markers” ) trace1 = go.Scatter( x = x_vals, y = y2, mode = ”lines+markers”, name = ”line+markers” ) trace2 = go.Scatter( x = x_vals, y = y3, mode = ”lines”, name = ”line” ) data = [trace0, trace1, trace2] fig = go.Figure(data = data) iplot(fig) The output of Jupyter notebook cell is as given below − Scattergl Plot WebGL (Web Graphics Library) is a JavaScript API for rendering interactive 2D and 3D graphics within any compatible web browser without the use of plug-ins. WebGL is fully integrated with other web standards, allowing Graphics Processing Unit (GPU) accelerated usage of image processing. Plotly you can implement WebGL with Scattergl() in place of Scatter() for increased speed, improved interactivity, and the ability to plot even more data. The go.scattergl() function which gives better performance when a large number of data points are involved. import numpy as np N = 100000 x = np.random.randn(N) y = np.random.randn(N) trace0 = go.Scattergl( x = x, y = y, mode = ”markers” ) data = [trace0] layout = go.Layout(title = “scattergl plot “) fig = go.Figure(data = data, layout = layout) iplot(fig) The output is mentioned below − Bubble charts A bubble chart displays three dimensions of data. Each entity with its three dimensions of associated data is plotted as a disk (bubble) that expresses two of the dimensions through the disk”s xy location and the third through its size. The sizes of the bubbles are determined by the values in the third data series. Bubble chart is a variation of the scatter plot, in which the data points are replaced with bubbles. If your data has three dimensions as shown below, creating a Bubble chart will be a good choice. Company Products Sale Share A 13 2354 23 B 6 5423 47 C 23 2451 30 Bubble chart is produced with go.Scatter() trace. Two of the above data series are given as x and y properties. Third dimension is shown by marker with its size representing third data series. In the above mentioned case, we use products and sale as x and y properties and market share as marker size. Enter the following code in Jupyter notebook. company = [”A”,”B”,”C”] products = [13,6,23] sale = [2354,5423,4251] share = [23,47,30] fig = go.Figure(data = [go.Scatter( x = products, y = sale, text = [ ”company:”+c+” share:”+str(s)+”%” for c in company for s in share if company.index(c)==share.index(s) ], mode = ”markers”, marker_size = share, marker_color = [”blue”,”red”,”yellow”]) ]) iplot(fig) The output would be as shown below − Print Page Previous Next Advertisements ”;
Plotly – Exporting to Static Images ”; Previous Next Outputs of offline graphs can be exported to various raster and vector image formats. For that purpose, we need to install two dependencies – orca and psutil. Orca Orca stands for Open-source Report Creator App. It is an Electron app that generates images and reports of plotly graphs, dash apps, dashboards from the command line. Orca is the backbone of Plotly”s Image Server. psutil psutil (python system and process utilities) is a cross-platform library for retrieving information on running processes and system utilization in Python. It implements many functionalities offered by UNIX command line tools such as: ps, top, netstat, ifconfig, who, etc. psutil supports all major operating systems such as Linux, Windows and MacOs Installation of Orca and psutil If you are using Anaconda distribution of Python, installation of orca and psutil is very easily done by conda package manager as follows − conda install -c plotly plotly-orca psutil Since, orca is not available in PyPi repository. You can instead use npm utility to install it. npm install -g [email protected] orca Use pip to install psutil pip install psutil If you are not able to use npm or conda, prebuilt binaries of orca can also be downloaded from the following website which is available at https://github.com/plotly/orca/releases. To export Figure object to png, jpg or WebP format, first, import plotly.io module import plotly.io as pio Now, we can call write_image() function as follows − pio.write_image(fig, ‘sinewave.png’) pio.write_image(fig, ‘sinewave.jpeg’) pio.write_image(fig,’sinewave.webp) The orca tool also supports exporting plotly to svg, pdf and eps formats. Pio.write_image(fig, ‘sinewave.svg’) pio.write_image(fig, ‘sinewave.pdf’) In Jupyter notebook, the image object obtained by pio.to_image() function can be displayed inline as follows − 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 ”;