Matplotlib.pyplot.xscale() function in Python Last Updated : 15 Jul, 2025 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. matplotlib.pyplot.xscale() function The xscale() function in pyplot module of matplotlib library is used to set the x-axis scale. Syntax: matplotlib.pyplot.xscale(value, \*\*kwargs) Parameters: This method accept the following parameters that are described below: value: This parameter is the axis scale type to apply.**kwargs: There are different keyword arguments which are accepted and its depend on the scale. Returns: This method does not returns any value. Below examples illustrate the matplotlib.pyplot.xscale() function in matplotlib.pyplot: Example 1: Python3 # Implementation of matplotlib function import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import EngFormatter val = np.random.RandomState(19680801) xs = np.logspace(1, 9, 100) ys = (0.8 + 4 * val.uniform(size = 100)) * np.log10(xs)**2 plt.xscale('log') plt.plot(xs, ys) plt.xlabel('Frequency') plt.title('matplotlib.pyplot.xscale() \ function Example\n', fontweight ="bold") plt.show() Output: Example 2: Python3 # Implementation of matplotlib function import numpy as np import matplotlib.pyplot as plt fig, ax4 = plt.subplots() x = 10.0**np.linspace(0.0, 2.0, 15) y = x**2.0 plt.xscale("log", nonposx ='clip') plt.yscale("log", nonposy ='clip') plt.errorbar(x, y, xerr = 0.1 * x, yerr = 2.0 + 1.75 * y, color ="green") plt.ylim(bottom = 0.1) plt.title('matplotlib.pyplot.xscale() \ function Example\n', fontweight ="bold") plt.show() Output: Comment More infoAdvertise with us Next Article Must Do Coding Questions - Topic-wise S shubhamsingh10 Follow Improve Article Tags : Python Python-matplotlib Matplotlib Pyplot-class Practice Tags : python Similar Reads Interview PreparationInterview Preparation For Software DevelopersMust Coding Questions - Company-wise Must Do Coding Questions - Topic-wiseCompany-wise Practice ProblemsCompany PreparationCompetitive ProgrammingSoftware Design-PatternsCompany-wise Interview ExperienceExperienced - Interview ExperiencesInternship - Interview ExperiencesPractice @GeeksforgeeksProblem of the DayTopic-wise PracticeDifficulty Level - SchoolDifficulty Level - BasicDifficulty Level - EasyDifficulty Level - MediumDifficulty Level - HardLeaderboard !!Explore More...Data StructuresArraysLinked ListStackQueueBinary TreeBinary Search TreeHeapHashingGraphAdvance Data StructuresMatrixStringAll Data StructuresAlgorithmsAnalysis of AlgorithmsSearching AlgorithmsSorting AlgorithmsPattern SearchingGeometric AlgorithmsMathematical AlgorithmsRandomized AlgorithmsGreedy AlgorithmsDynamic ProgrammingDivide & ConquerBacktrackingBranch & BoundAll AlgorithmsProgramming LanguagesCC++JavaPythonC#Go LangSQLPHPScalaPerlKotlinWeb TechnologiesHTMLCSSJavaScriptBootstrapTailwind CSSAngularJSReactJSjQueryNodeJSPHPWeb DesignWeb BrowserFile FormatsComputer Science SubjectsOperating SystemsDBMSComputer NetworkComputer Organization & ArchitectureTOCCompiler DesignDigital Elec. & Logic DesignSoftware EngineeringEngineering MathematicsData Science & MLComplete Data Science CourseData Science TutorialMachine Learning TutorialDeep Learning TutorialNLP TutorialMachine Learning ProjectsData Analysis TutorialTutorial LibraryPython TutorialDjango TutorialPandas TutorialKivy TutorialTkinter TutorialOpenCV TutorialSelenium TutorialGATE CSGATE CS NotesGate CornerPrevious Year GATE PapersLast Minute Notes (LMNs)Important Topic For GATE CSGATE CoursePrevious Year Paper: CS exams Like