Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Pandas
  • Numpy
  • Seaborn
  • Ploty
  • Data visualization
  • Data Analysis
  • Power BI
  • Tableau
  • Machine Learning
  • Deep Learning
  • NLP
  • Computer Vision
  • Data Science for Beginners
  • Data Science interview questions
  • Data analysis interview questions
  • NLP Interview questions
Open In App
Next Article:
Matplotlib.pyplot.ylim() in Python
Next article icon

Matplotlib.pyplot.xlim() in Python

Last Updated : 13 Mar, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report
Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, etc. #Sample Code Python3 1==
# 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: The **kwargs parameter in Python functions stands for "keyword arguments". It allows you to pass a variable number of keyword arguments to a function.
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: Python3 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: Python3 1==
# 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:

Next Article
Matplotlib.pyplot.ylim() in Python

S

SHUBHAMSINGH10
Improve
Article Tags :
  • Python
  • Write From Home
  • Python-matplotlib
  • Matplotlib Pyplot-class
Practice Tags :
  • python

Similar Reads

  • Matplotlib.pyplot.ylim() in Python
    Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. matplotlib.pyplot.ylim() Function The ylim() function in pyplot module of matplotlib library is used to g
    2 min read
  • Matplotlib.pyplot.sci() in Python
    Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot,
    2 min read
  • Matplotlib.pyplot.xticks() in Python
    matplotlib.pyplot.xticks() function is used to get or set the x-axis ticks in a plot. This function allows you to modify the labels and positions of the ticks along the x-axis, providing greater flexibility and control over your plots. Let's see an example to better understand this. Example: Set Cus
    3 min read
  • Matplotlib.pyplot.xkcd() in Python
    One of the main process in Data Science is Data Visualization. Data Visualization refers to present a dataset in the form of graphs and pictures. We can identify upcoming trend by observing these Graphs. Python provides us with an amazing Data Visualization library in it which is Matplotlib which wa
    2 min read
  • Matplotlib.pyplot.xlabels() in Python
    Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. matplotlib.pyplot.xlabel() Function The xlabel() function in pyplot module of matplotlib library is used
    2 min read
  • Matplotlib.pyplot.sca() in Python
    Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot,
    1 min read
  • Matplotlib.pyplot.twiny() in Python
    Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. Sample Code # sample code import matplotlib.pyplot as plt plt.plot([1, 2, 3, 4], [16, 4, 1, 8]) plt.show(
    2 min read
  • Matplotlib.pyplot.twinx() in Python
    Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. Sample Code # sample code import matplotlib.pyplot as plt plt.plot([1, 2, 3, 4], [16, 4, 1, 8]) plt.show(
    2 min read
  • Matplotlib.pyplot.title() in Python
    The title() method in the Matplotlib module is used to specify the title of the visualization depicted and display the title using various attributes. In this article, we will learn about this function with the help of examples. Syntax: matplotlib.pyplot.title(label, fontdict=None, loc='center', pad
    3 min read
  • Matplotlib.pyplot.show() in Python
    Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. Sample Code - # sample code import matplotlib.pyplot as plt plt.plot([1, 2, 3, 4], [16, 4, 1, 8]) plt.sho
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences