# Matplotlib.pyplot.xlim() in Python

## Matplotlib.pyplot.xlim() in Python

There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, etc.
#Sample Code

 # sample code import matplotlib.pyplot as plt      plt.plot([1, 2, 3, 4], [16, 4, 1, 8])  plt.show()

Output:

## matplotlib.pyplot.xlim() Function

The xlim() function in pyplot module of matplotlib library is used to get or set the x-limits of the current axes.
Syntax:

matplotlib.pyplot.xlim(*args, **kwargs)

Parameters: This method accept the following parameters that are described below:

• left: This parameter is used to set the xlim to left.
• right: This parameter is used to set the xlim to right.
• **kwargs: This parameter is Text properties that is used to control the appearance of the labels.

Returns: This returns the following:

• left, right: This returns the tuple of the new x-axis limits.

Below examples illustrate the matplotlib.pyplot.ylim() function in matplotlib.pyplot:

Example-1:

 # Implementation of matplotlib function import matplotlib.pyplot as plt import numpy as np   h = plt.plot(np.arange(0, 10), np.arange(0, 10)) plt.xlim([-5, 20]) l1 = np.array((1, 1)) angle = 65   th1 = plt.text(l1[0], l1[1], 'Line_angle',                fontsize = 10, rotation = angle,                rotation_mode ='anchor')   plt.title(" matplotlib.pyplot.xlim() Example") plt.show()

Output:

Example-2:

 # Implementation of matplotlib function import matplotlib.pyplot as plt import numpy as np   np.random.seed(9680801)   mu, sigma = 50, 13 x = mu + sigma * np.random.randn(10000)   # the histogram of the data n, bins, patches = plt.hist(x, 50,                             density = True,                              facecolor ='g',                              alpha = 0.75)     plt.xlabel('No of Users in K') plt.title('Histogram of IQ') plt.text(50, .035, r'$\mu = 50, \  \ \sigma = 13$')   plt.xlim(-10, 110) plt.ylim(0, 0.04)   plt.grid(True) plt.title(" matplotlib.pyplot.xlim() Example") plt.show()

Output:

Last Updated on March 17, 2022 by admin

## Find the k most frequent words from data set in PythonFind the k most frequent words from data set in Python

Find the k most frequent words from data set in Python Given the data set,

## Python – Get key from value in DictionaryPython – Get key from value in Dictionary

Python | Get key from value in Dictionary Let’s see how to get the key

## Python PIL – ImageDraw.Draw.rectangle()Python PIL – ImageDraw.Draw.rectangle()

Python PIL | ImageDraw.Draw.rectangle() PIL is the Python Imaging Library which provides the python interpreter

## IntegerField – Django ModelsIntegerField – Django Models

IntegerField – Django Models IntegerField is a integer number represented in Python by a int instance. This field

Python | Pandas Dataframe/Series.head() method Python is a great language for doing data analysis, primarily

## Python – Check if all the values in a list that are greater than a given valuePython – Check if all the values in a list that are greater than a given value

Python | Check if all the values in a list that are greater than a

## Progressbar widget in Tkinter – PythonProgressbar widget in Tkinter – Python

Tkinter Progressbar widget The purpose of this widget is to reassure the user that something

## XGBoost for RegressionXGBoost for Regression

XGBoost for Regression The results of the regression problems are continuous or real values. Some