Print Celsius Symbol with Matplotlib

Rishikesh Kumar Rishi
Updated on 10-Jun-2021 11:59:08

1K+ Views

To print Celsius symbol with Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Initialize a variable, N.Create T and P data points using numpy.Plot T and P using plot() method.Set the label for the X-axis.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True N = 10 T = np.random.rand(N) P = np.random.rand(N) plt.plot(T, P) plt.xlabel("$Temperature {^\circ}C$") plt.show()Output

Automated Legend Creation in Matplotlib

Rishikesh Kumar Rishi
Updated on 10-Jun-2021 11:58:42

907 Views

To automate legend creation 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, for number of sample data.Create x, y, c and s data using numpy.Create a figure and a set of subplots using subplots() method.Plot x and y data points with different colors and sizes.Place a legend on the axes.Add an artist to the figure.Create legend handles and labels for a PathCollection.Again, place a legend on the axes for sizes.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np ... Read More

Plot Nested Pie Chart in Matplotlib

Rishikesh Kumar Rishi
Updated on 10-Jun-2021 11:58:13

2K+ Views

To plot a nested pie chart in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots.Initialize a variable size, create vals, cmap, outer_colors, inner_colors data using numpy.Use pie() function to make pie charts.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() size = 0.3 vals = np.array([[60., 32.], [37., 40.], [29., 10.]]) cmap = plt.get_cmap("tab20c") outer_colors = cmap(np.arange(3)*4) inner_colors = cmap([1, 2, 5, 6, 9, ... Read More

Set NetworkX Edge Labels Offset in Matplotlib

Rishikesh Kumar Rishi
Updated on 10-Jun-2021 11:57:42

1K+ Views

To set the networkx edge labels offset, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Initialize a graph with edges, name, or graph attributes.Add multiple nodes.Add all the edges using add_edge_from() method.Position the nodes using Fruchterman-Reingold force-directed algorithm.Draw the graph G with Matplotlib.Draw edge labels.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() G.add_nodes_from([1, 2, 3, 4]) G.add_edges_from([(1, 2), (2, 3), (3, 4), (4, 1), (1, 3)]) pos = nx.spring_layout(G) ... Read More

Plot Stem Plot in Matplotlib Python

Rishikesh Kumar Rishi
Updated on 10-Jun-2021 11:56:19

4K+ Views

To plot a stem plot in Matplotlib, we can use stem() method. It creates vertical lines from a baseline to the Y-coordinate and places a marker at the tip.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Create a stem plot using stem() method.Set the marker face color with red color.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(0.1, 2 * np.pi, 41) y = np.exp(np.sin(x)) markerline, stemlines, baseline = plt.stem(x, y, ... Read More

Refresh Text in Matplotlib

Rishikesh Kumar Rishi
Updated on 10-Jun-2021 11:49:05

2K+ Views

To refresh text in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots.Add text to the axes.Write customized method to update text based on the keys "z" and "c".Bind the function action with key_press_event.Draw the canvas that contains the figure.Animate the figure with texts.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt, animation plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() text = ax.text(.5, .5, 'First Text') def action(event):    if event.key == "z":   ... Read More

Make XTicks Evenly Spaced Despite Their Values in Matplotlib

Rishikesh Kumar Rishi
Updated on 10-Jun-2021 11:48:42

4K+ Views

To make xticks evenly spaced despite their values, we can use set_ticks() and set_ticklabels() methods.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Create a figure and a set of subplots using subplots() method.Plot x and y data points on axis 1.Set xticks using xaxis.set_ticks() method.Plot x and y data points on axis 2.Set xticks and ticklabels using xaxis.set_ticks() and xaxis.set_ticklabels() 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.array([1, 1.5, ... Read More

Stuff a Pandas DataFrame Plot into a Matplotlib Subplot

Rishikesh Kumar Rishi
Updated on 10-Jun-2021 11:47:56

2K+ Views

To stuff a Pandas dataframe plot into a Matplotlib subplot, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots, two axes.Create a Pandas dataframe using DataFrame.Use DataFrame.plot() method to plot.To display the figure, use show() method.Exampleimport pandas as pd import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, (ax1, ax2) = plt.subplots(2) df = pd.DataFrame(dict(name=["Joe", "James", "Jack"], age=[23, 34, 26])) df.set_index("name").plot(ax=ax1) df.set_index("name").plot(ax=ax2) plt.show()OutputRead More

Average and RMS Value of Alternating Current and Voltage

Manish Kumar Saini
Updated on 10-Jun-2021 08:53:42

46K+ Views

Average Value of Alternating QuantityThe arithmetical average of all the instantaneous values of an alternating quantity over one cycle is known as the "Average Value of Alternating Quantity".$$Average\:value=\frac{Sum\:of\:all\:instantaneous\:values\:over\:one\:cycle}{Number\:of\:instants}$$$$=\frac{Total\:are\:under\:the\:curve\:for\:time\:period\:T}{Time\:Period\:(T)} $$$$=\frac{i_{1}+i_{2}+i_{3}+...+i_{n}}{n}$$Average Value of Symmetrical WavesIn case of symmetrical waves like sinusoidal voltage or current, the average value over one cycle is zero. It is because the positive half cycle is exactly equal to the negative half cycle. But the average value of positive or negative half cycle is not zero. Therefore, in case of symmetrical waves, the average value is calculated for half cycle.$$Avg\:value = \frac{Sum\:of\:all\:instantaneous\:values\:over\:half\:cycle}{Number\:of\:instants\:of\:half\:cycle}$$Average Value of Unsymmetrical WaveIn case of ... Read More

What is Static Testing and Testing Review

Vineet Nanda
Updated on 09-Jun-2021 12:56:43

2K+ Views

What is Static Testing?Static testing is a software testing methodology used to look for faults in software applications without running the program. Static testing is used to prevent problems at an early stage of development since it is easier to notice and correct faults at this point. It also aids in the detection of faults that Dynamic Testing may miss.Dynamic Testing, on the other hand, examines an application while the code is executed.Static testing methodologies are classified into two groups −Manual examinations − Manual examinations contain manual code analysis, often called REVIEWS.Automated analysis using tools − Automated analysis is essentially ... Read More

Advertisements