Matplotlib.pyplot.ylabels () в Python
Matplotlib - это библиотека на Python, которая является численно-математическим расширением библиотеки NumPy. Pyplot - это интерфейс на основе состояний для модуля Matplotlib, который предоставляет интерфейс, подобный MATLAB.
Функция matplotlib.pyplot.ylabel ()
Функция ylabel () в модуле pyplot библиотеки matplotlib используется для установки метки для оси x.
Syntax: matplotlib.pyplot.ylabel(ylabel, fontdict=None, labelpad=None, **kwargs)
Parameters: This method accept the following parameters that are described below:
- ylabel: This parameter is the label text. And contains the string value.
- labelpad: This parameter is used for spacing in points from the axes bounding box including ticks and tick labels and its default value is None.
- **kwargs: This parameter is Text properties that is used to control the appearance of the labels.
Примеры ниже иллюстрируют функцию matplotlib.pyplot.ylabel () в matplotlib.pyplot:
Example #1:
# Implementation of matplotlib.pyplot.ylabels() # function import numpy as np import matplotlib.pyplot as plt t = np.arange( - 180.0 , 180.0 , 0.1 ) s = np.radians(t) / 2. plt.plot(t, s, "-" , lw = 2 ) plt.xlabel( "Longitude" ) plt.ylabel( "Latitude" ) plt.title( "ylabels() function" ) plt.grid( True ) plt.show() |
Выход:
Example #2:
# Implementation of matplotlib.pyplot.ylabels() # function import numpy as np import matplotlib.pyplot as plt valx1 = np.linspace( 0.0 , 5.0 ) x2 = np.linspace( 0.0 , 2.0 ) valy1 = np.cos( 2 * np.pi * valx1) * np.exp( - valx1) y2 = np.cos( 2 * np.pi * x2) plt.subplot( 2 , 1 , 1 ) plt.plot(valx1, valy1, "o-" ) plt.title( "ylabel() Example" ) plt.ylabel( "Damped oscillation" ) plt.subplot( 2 , 1 , 2 ) plt.plot(x2, y2, ".-" ) plt.xlabel( "time (s)" ) plt.ylabel( "Undamped" ) plt.show() |
Выход:
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.