What is Pre-request Scripts in Postman

Debomita Bhattacharjee
Updated on 03-Aug-2021 12:47:05

975 Views

The Pre-Request scripts are executed before the execution of requests. These scripts are implemented in JavaScript and mainly created to execute pre-requisite conditions like declaring request headers, parameters, variables, or an output.We can create Pre-Request Script to define the sequence of execution of requests in a Collection. A Pre-Request Script is also utilized for scenarios where value returned from a request is required in the following request or a value returned from a request should be captured prior to the next request.These scripts are defined in the Pre-request Script tab in Postman.Incorporate the below JavaScript in the Pre-Request Script tab ... Read More

Use Font Awesome Symbol as Marker in Matplotlib

Rishikesh Kumar Rishi
Updated on 03-Aug-2021 12:41:02

313 Views

To use Font Awesome symbol as a marker, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a list of symbols; has to be plotted.Create x and y data points using numpy.Create a new figure or activate an existing figure using figure() method.Iterate the symbols and use it while plotting a line.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 symbols = [u'\u2B21', u'\u263A', u'\u29C6', u'\u2B14', u'\u2B1A', u'\u25A6', u'\u229E', u'\u22A0', u'\u22A1', u'\u20DF'] x = np.arange(10) ... Read More

Plot Image with Non-Linear Y-Axis Using Matplotlib

Rishikesh Kumar Rishi
Updated on 03-Aug-2021 12:35:11

976 Views

To plot an image with non-linear Y-axis with matplotlib using imshow() method, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Add a subplot to the current figure.Set nonlinear Y-axis ticks.Create random data points using numpy.Display data as an image, i.e., on a 2D regular raster, with data.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 ax = plt.subplot(111) ax.yaxis.set_ticks([0, 2, 4, 8]) data = np.random.randn(5, 5) plt.imshow(data, cmap='copper') plt.show()OutputRead More

Create Matplotlib Colormap that Treats One Value Specially

Rishikesh Kumar Rishi
Updated on 03-Aug-2021 12:33:09

606 Views

To create a matplotlib colormap that treats one value specially, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Get a colormap instance, name is "rainbow".Set the color for low out-of-range values, using set_under('red') method.Create random data and eps using numpy.Create a figure and a set of subplots.Display data as an image, i.e., on a 2D regular raster, using imshow() method.Create a colorbar for a ScalarMappable instance, im.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 cmap ... Read More

Show Closed Figure in Matplotlib

Rishikesh Kumar Rishi
Updated on 03-Aug-2021 12:31:25

980 Views

To show a figure that has been closed in Matplotlib, we can create a new Canvas Manager and store the previous figure into a new Canvas figure.StepsSet the figure size and adjust the padding between and around the subplots.Create a new figure or activate an existing figure.Create x and y data points using numpy.Plot x and y data points using plot() method.Close the current figure where the plot has been plotted.Now, store the previous figure in a new Canvas figure.Set the Canvas that contains the figure.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as ... Read More

Set Y-Axis in Radians in a Python Plot

Rishikesh Kumar Rishi
Updated on 03-Aug-2021 12:29:24

945 Views

To set the Y-axis in radians in a Python plot, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x and y data point using numpy.Create a new figure or activate an existing figure using figure() method.Add an axes, ax, to the figure as part of a subplot arrangement.Get the list of Y-axis ticks and ticklabels.Set the ticks and ticklabels using set_yticks() and set_yticklabels() methods.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.arange(-10.0, ... Read More

Plot Histograms from DataFrames in Pandas using Matplotlib

Rishikesh Kumar Rishi
Updated on 03-Aug-2021 12:24:36

594 Views

To plot histograms against Pandas/Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a potentially hetrogeneous tabular data using Pandas dataframe.Use the dataframe to make a histogram.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import pandas as pd plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame({'a': [1, 1, 1, 1, 3],    'b': [1, 1, 2, 1, 3],    'c': [2, 2, 2, 1, 3],    'd': [2, 1, 2, 1, 3], }) df.hist() plt.show()Output

Overlay Box Plot on Swarm Plot in Seaborn

Rishikesh Kumar Rishi
Updated on 03-Aug-2021 12:22:32

529 Views

To plot a Box plot overlaid on top of a Swarm plot in Seaborn, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a Pandas dataframe, i.e., two-dimensional, size-mutable, potentially heterogeneous tabular data.Initialize the plotter, swarmplot.To plot the box plot, use boxplot() method.To display the figure, use show() method.Exampleimport seaborn as sns import matplotlib.pyplot as plt import pandas as pd import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = pd.DataFrame({"Box1": np.arange(10), "Box2": np.arange(10)}) ax = sns.swarmplot(x="Box1", y="Box2", data=data, zorder=0) sns.boxplot(x="Box1", y="Box2", data=data, showcaps=False, ... Read More

Setting Display Range of Subplot for Error Bars in Matplotlib

Rishikesh Kumar Rishi
Updated on 03-Aug-2021 12:17:31

128 Views

To set the display range subplot or errorbars in matplotlib, we can take the following steps −Set 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.Plot y versus x as lines and/or markers with attached errorbars.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 = np.arange(0.1, 4, 0.5) y = np.exp(-x) fig, ax = plt.subplots() ax.errorbar(x, y, xerr=0.2, yerr=0.4) plt.show()OutputRead More

Adjust Width of Box in Boxplot using Python Matplotlib

Rishikesh Kumar Rishi
Updated on 03-Aug-2021 12:14:33

7K+ Views

To adjust the width of box in boxplot in Python matplotlib, we can use width in the boxplot() method.StepsSet the figure size and adjust the padding between and around the subplots.Make a Pandas dataframe, i.e., two-dimensional, size-mutable, potentially heterogeneous tabular data.Make a box and whisker plot, using boxplot() method with width tuple to adjust the box in boxplot.To display the figure, use show() method.Exampleimport pandas as pd import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = pd.DataFrame({"Box1": np.random.rand(10), "Box2": np.random.rand(10)}) ax = plt.boxplot(data, widths=(0.25, 0.5)) plt.show()OutputRead More

Advertisements