To save image for maximized window instead of default size, we can use the following Steps −Create figure with figsize=(7.50, 3.50), using the figure() method.Plot the lines using the plot() method with list, color=”red”, and linewidth=2.Save the figure using the savefig() method.To display the figure, use the show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() plt.plot([1, 3, 7, 3, 1], c="red", lw=2) plt.savefig("full_image.png") plt.show()Output
To show multiple figures in matplotlib, we can take the following Steps −To create a new figure, or activate an existing figure, use the figure() method. (Create two figures namely, Figure1 and Figure2).Plot the lines with the same lists (colors red and green and linewidth 2 and 5).Set the title of the plot over both the figures.To display the figure, use the show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig1 = plt.figure("Figure 1") plt.plot([1, 3, 7, 3, 1], c="red", lw=2) plt.title("I am the part of figure 1") fig2 = plt.figure("Figure 2") plt.plot([1, 3, ... Read More
To position a textbox automatically in matplotlib, we can take the following Steps −Create xpoints from 1 to 2 and 100 samples.Create y1points and y2points using xpoints (Step 1) and numpy.Plot xpoints, y1points and y2points using the plot() method.To set the label, use the legend() method. It will help to position the text box.To display the figure, use the 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 xpoints = np.linspace(1, 2, 100) y1points = np.log(xpoints) y2points = np.exp(xpoints) plt.plot(xpoints, y1points, label="Log") plt.plot(xpoints, y2points, label="Exp") plt.legend() plt.show()OutputRead More
Definingadd_axes − Add an axes to the figure.add_subplot − Add an axes to the figure as part of a subplot arrangement.StepsCreate a new figure, or activate an existing figure, using the figure() method.Add an axes to the figure as part of a subplot arrangement where nrows=2, ncols=2. At index 1, add the title "subtitle1" and at index 2, add the title "subplot2".Create points for four rectangles and use add_axes() method to add an axes to the figure.To display the figure, use the show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() fig.add_subplot(221) plt.title("subplot1") fig.add_subplot(222) ... Read More
To change the color of a line using radiobuttons, we can take the following steps −Create x, sin and cos data points using numpy.Adjust the figure size and padding between and around the subplots.Create a figure and a set of subplots using the subplots() method.Plot curve with x and y data points using the plot() method.Add an axes to the current figure and make it the current axes, using the axes() method.Add a radio button to the current axes.To change the curve with radionbutton, we can use the change_curve() method that can be passed in on_clicked() method.To display the figure, use the show() method.Exampleimport numpy ... Read More
To detect outliers in one dimensional observation data, we can take the following Steps −Create spread, center, flier_high and flier_low.Using the above data (Step 1), we can calculate data.Use the suplots() method to create a figure and a set of subplots, i.e., fig1 and ax1.Set the title of ax1.Now using the boxplot() method and data, make a box and a whisker plot. Beyond the whiskers, data are considered outliers and are plotted as individual points.To display the figure, use the 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 np.random.seed(19680801) spread ... Read More
We can automate Google Signup form with Selenium webdriver in Python. To automate this page, we have to first launch the Google Signup page and identify each element on the form.Let us have a look at the Google Signup form −Examplefrom selenium import webdriver #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") #implicit wait driver.implicitly_wait(0.5) #launch URL driver.get("https://accounts.google.com/signup") #identify elements within form f = driver.find_element_by_id("firstName") f.send_keys("Test") l = driver.find_element_by_id("lastName") l.send_keys("One") u = driver.find_element_by_id("username") u.send_keys("test124ewin") p = driver.find_element_by_name("Passwd") p.send_keys("test124@") c = driver.find_element_by_name ("ConfirmPasswd") c.send_keys("test124@") #get value entered s = f.get_attribute("value") t = l.get_attribute("value") v = u.get_attribute("value") w = p.get_attribute("value") print("Values entered in form: ... Read More
We can handle SSL certificate with Selenium webdriver in Chrome browser. A SSL is the standardized protocol used to create a connection between the browser and server.The information exchanged via a SSL certificate is encrypted and it verifies if the information is sent to the correct server. It authenticates a website and provides protection from hacking.An untrusted SSL certificate error is thrown if there are problems in the SSL certificate. We shall receive such an error while we launch a website. In Chrome, we use the ChromeOptions class to work with SSL certificates.We shall create an instance of this class ... Read More
We can perform session handling with the help of Selenium webdriver with a TestNG framework. To trigger different sessions, we shall use the attribute parallel in the TestNG XML file.A TestNG execution configuration is done in the TestNG XML. To create multiple sessions, we shall add the attributes – parallel and thread-count in the XML file.The attribute thread-count controls the number of sessions to be created while executing the tests in a parallel mode. The value of parallel attribute is set to methods.In our example, we would have three methods with three different session ids which are executing in parallel.Exampleimport ... Read More
We can install the Selenium package in Anaconda. The conda has multiple packages so that it can be integrated with Selenium, Selenium-pytest, and so on from the below link − https://anaconda.org/searchA conda is a command line tool in the form of a package which is used for Anaconda.It has some similarities with pip. Selenium is present within the community based conda-forge channel available from the below link − https://anaconda.org/conda-forge/seleniumTo complete installation of this package, we can execute any of the below commands −conda install -c conda-forge seleniumconda install -c conda-forge/label/gcc7 seleniumconda install -c conda-forge/label/cf201901 seleniumconda install -c conda-forge/label/cf202003 seleniumRead More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP