Articles on Trending Technologies

Technical articles with clear explanations and examples

How to create a surface plot from a greyscale image with Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 23-Sep-2021 1K+ Views

To create a surface plot from a grayscale image with matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create random data points using Numpy.Get the xx and yy data points from a 2d image data raster.Create a new figure or activate an existing figure.Get the current axis of the plot and make it 3d projection axes.Create a surface plot with cmap='gray'.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 data = np.random.rand(5, 5) xx, ...

Read More

How to remove the first and last ticks label of each Y-axis subplot in Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 23-Sep-2021 3K+ Views

To remove the first and last ticks label of each Y-axis 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.Iterate the axes and set the first and last ticklabel's visible=False.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots(2, sharex=True) for a in ax:    plt.setp(a.get_yticklabels()[0], visible=False)    plt.setp(a.get_yticklabels()[-1], visible=False) plt.show()Output

Read More

How to extract only the month and day from a datetime object in Python?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 23-Sep-2021 2K+ Views

To extract only the month and day from a datetime object in Python, we can use the DateFormatter() class.stepsSet the figure size and adjust the padding between and around the subplots.Make a dataframe, df, of two-dimensional, size-mutable, potentially heterogeneous tabular data.Create a figure and a set of subplots.Plot the dataframe using plot() method.Set the axis formatter, extract month and day.To display the figure, use show() method.Exampleimport numpy as np import pandas as pd from matplotlib import pyplot as plt, dates plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame(dict(time=list(pd.date_range("2021-01-01 12:00:00", periods=10)), speed=np.linspace(1, 10, 10))) fig, ax = ...

Read More

How to remove whitespaces at the bottom of a Matplotlib graph?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 23-Sep-2021 4K+ Views

To remove whitespaces at the bottom of a Matplotlib graph, we can use tight layout or autoscale_on=False.stepsSet the figure size and adjust the padding between and around the subplots.Create a new figure or activate an existing figure.Add an 'ax' to the figure as part of a subplot arrangement.Plot a list of data points using plot() method.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.add_subplot(111, autoscale_on=False, xlim=(1, 5), ylim=(0, 10)) ax.plot([2, 5, 1, 2, 0, 7]) plt.show()Output

Read More

How to understand Seaborn's heatmap annotation format?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 23-Sep-2021 2K+ Views

To understand Seaborn's heatmap annotation format, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a Pandas dataframe with five columns.Plot the rectangular data as a color-encoded matrix, fmt=".2%" represents the annotation format.To display the figure, use show() method.ExampleExampleimport seaborn as sns import pandas as pd import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame(np.random.random((5, 5)), columns=["a", "b", "c", "d", "e"]) sns.heatmap(df, annot=True, annot_kws={"size": 7}, fmt=".2%") plt.show()Output

Read More

How to create a 100% stacked Area Chart with Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 23-Sep-2021 1K+ Views

To create a 100% stacked Area Chart with Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a list of years.Make a dictionary, with list of population in respective years.Create a figure and a set of subplots.Draw a stacked Area Plot.Place a legend on the figure, at the location ''upper left''.Set the title, xlabel and ylabel.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True year = [1950, 1960, 1970, 1980, 1990, 2000, 2010, 2018] population_by_continent = {   ...

Read More

Python Pandas – Create a subset and display only the last entry from duplicate values

AmitDiwan
AmitDiwan
Updated on 22-Sep-2021 1K+ Views

To create a subset and display only the last entry from duplicate values, use the “keep” parameter with the ‘last” value in drop_duplicates() method. The drop_duplicates() method removed duplicates.Let us first create a DataFrame with 3 columns −dataFrame = pd.DataFrame({'Car': ['BMW', 'Mercedes', 'Lamborghini', 'BMW', 'Mercedes', 'Porsche'], 'Place': ['Delhi', 'Hyderabad', 'Chandigarh', 'Delhi', 'Hyderabad', 'Mumbai'], 'UnitsSold': [85, 70, 80, 95, 55, 90]})Removing duplicates and displaying last entry. Using keep parameter, we have set "last". Duplicate rows except the last entry will get deleted. We have considered a subset using the “subset” parameter −dataFrame2 = dataFrame.drop_duplicates(subset = ['Car', 'Place'], keep ='last').reset_index(drop = True)ExampleFollowing ...

Read More

REST API Testing Tutorial - Sample Manual Test Case

Vineet Nanda
Vineet Nanda
Updated on 22-Sep-2021 15K+ Views

APIApplication Programming Interface is a computing interface that communicates and helps exchange information between two separate systems. A system that executes an API involves functions that another system can also perform. It defines requests to be made, how to make the requests, formats that can be used, etc. between two different systems.API TestingIt is a software testing that evaluates APIs. Its purpose is to determine the functionality, dependability, performance, and security of the interfaces. Rather than standard user inputs such as keyboards and outputs, we use software to send calls, obtain output, and record the response of the system. These ...

Read More

Python – Merge two Pandas DataFrame

AmitDiwan
AmitDiwan
Updated on 22-Sep-2021 857 Views

To merge two Pandas DataFrame, use the merge() function. Just set both the DataFrames as a parameter of the merge() function.At first, let us import the required library with alias “pd” −import pandas as pdCreate the 1st DataFrame −# Create DataFrame1 dataFrame1 = pd.DataFrame(    {       "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'], "Units": [100, 150, 110, 80, 110, 90]    } )Next, create the 2nd DataFrame −# Create DataFrame2 dataFrame2 = pd.DataFrame(    {       "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Mercedes', 'Jaguar'], "Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000] } ...

Read More

Reliability Testing Tutorial (What is, Methods, Tools, Example)

Vineet Nanda
Vineet Nanda
Updated on 22-Sep-2021 1K+ Views

The chance of failure-free software execution for a set period of time in a given environment is defined as reliability.People nowadays naively believe in any program in this mechanized environment. People believe that whatever outcome the software system produces is always correct, therefore they follow it. That is a common mistake that we all make.Users believe that the data displayed is correct and that the software will always work properly. This is where the requirement for reliability testing arises.Reliability TestingReliability testing is a software testing procedure that determines if a piece of software can operate without fail for a set ...

Read More
Showing 28141–28150 of 61,248 articles
Advertisements