The percentage of completion method recognizes all the revenue and profit associated with long-term projects on proportion/percentage of work completed.In this method, revenue is recognized yearly. Sellers can recognize gain/loss in a project in every accounting year. This method estimates stages of project completion or estimates costs of remaining costs. This method falls in IFRS 15.The formula for the percentage of completion method is as follows −Revenue (to recognized) = percentage of completed work * total contract valueTypesThe types of the percentage of completion method are as follows −Cost to cost methodPercentage of work completed = total expenses incurred (accounting ... Read More
To animate 3D plot_surface in Matplotlib, we can take the following steps−Initialize variables for number of mesh grids (N), frequency per second (fps) to call a function, and frame numbers (frn).Create x, y and z array for a curve.Make a function to make a z-array using lambda function.To pass a function into animation class, make a user-defined function that removes the previous plot and plot a surface using x, y and z-array.Create a new figure or activate an existing figure.Add a subplot arrangement using subplots() method.Set the Z-axis limit using set_zlim() method.Call the animation class to animate the surface plot.To ... Read More
To combine several matplotlib axes subplots into one figure, we can use subplots() method with nrow=2.StepsSet the figure size and adjust the padding between and around the subplots.Create x, y1 and y2 data points using numpy.Create a figure and a set of subplots.Plot x, y1 and y2 data points using plot() method.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-10, 10, 100) y1 = np.sin(x) y2 = np.cos(x) fig, axes = plt.subplots(nrows=2) line1, = axes[0].plot(x, y1, color='red') line2, ... Read More
To get xkcd font working, we can use plt.xkcd() to turn on sketch-style drawing mode.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Use plt.xkcd() to turn on sketch-style drawing mode.Create a new figure or activate an existing figure.Add an axis to the figure as part of a subplot arrangement.Plot x and y data points using plot() method.Place a text and title on the plot.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x ... Read More
To make colorbar orientation horizontal in Python, we can use orientation="horizontal" in the argument.StepsSet the figure size and adjust the padding between and around the subplots.Create random x, y and z data points using numpy.Create a figure and a set of subplots.Use scatter() method to plot x, y and z data points.Create a colorbar for a ScalarMappable instance, with horizontal orientation.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x, y, z = np.random.rand(3, 50) f, ax = plt.subplots() points = ax.scatter(x, y, c=z, s=50, ... Read More
To show points coordinate in a plot in Python, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create lists of x and y data points.Plot x and y data points with red color and starred markerSet some axis properties.Iterate x and y to show the coordinates on the plot.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = [3, 1, 2, 5] y = [5, 2, 4, 7] plt.plot(x, y, 'r*') plt.axis([0, 6, 0, 20]) for i, j in zip(x, y): plt.text(i, ... Read More
To fill a polygon with a custom hatch in matplotlib, we can override the matplotlib.hatch.Shapes class.StepsSet the figure size and adjust the padding between and around the subplots.Make a hatch shape using polygon class and get the path.Override the custom hatch shape class, with shape_vertices, shape_codes, etc.Create a new figure or activate an existing figure.Add an axes to the figure as part of a subplot arrangement.Add an axes patch of shape polygon.Set the hatching pattern.To display the figure, use show() method.Exampleimport matplotlib.hatch import matplotlib.pyplot as plt from matplotlib.patches import Polygon plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True my_hatch_shape ... Read More
To create curved edges with NetworkX in Python3, we can use connectionstyle="arc3, rad=0.4".StepsSet the figure size and adjust the padding between and around the subplots.Initialize a graph with edges, name, and graph attributes.Add nodes to the created graph.Add edges from one node to another.Draw the graph G with Matplotlib, with connectionstyle="arc3, rad=0.4".To display the figure, use show() method.Exampleimport matplotlib.pylab as plt import networkx as nx plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True G = nx.DiGraph() pos = nx.spring_layout(G) G.add_nodes_from([1, 2, 3, 4]) G.add_edges_from([(1, 2), (2, 4), (2, 3), (4, 1)]) nx.draw(G, with_labels=True, connectionstyle="arc3, rad=0.4") plt.show()OutputRead More
To create a diverging stacked bar chart in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Initialize a variable N to get the number of indices.Get menMeans, womenMeans, menStd and womenStd tuple.Initialize the width of bars.Create a figure and a set of subplots.To get diverging bar, we can put the data with positive and negative values to make diverging bars.Add a horizontal line across the axis.Set Ylabel, title, ticks, ticklabels, and legend.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, ... Read More
To use Matplotlib to plot PySpark SQL results, we can take the following steps−Set the figure size and adjust the padding between and around the subplots.Get the instance that is the main Entry Point for Spark functionality.Get the instance of a variant of Spark SQL that integrates with the data stored in Hive.Make a list of records as a tuple.Distribute a local Python collection to form an RDD.Map the list record as a DB schema.Get the schema instance to make an entry into "my_table".Insert a record into a table.Read the SQL query, retrieve the record.Convert the fetched record into a ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP