Matplotlib.artist.Artist.set_label() in Python Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Artist class contains Abstract base class for objects that render into a FigureCanvas. All visible elements in a figure are subclasses of Artist. Matplotlib.artist.Artist.set_label() Method The set_label() method in artist module of matplotlib library is used to set the label that will be displayed in the legend. Syntax: Artist.set_label(self, s) Parameters: This method accepts only one parameters. s: This parameter is converted to a string by calling str. Returns: This method does not return any value. Below examples illustrate the matplotlib.artist.Artist.set_label() function in matplotlib: Example 1: python3 # Implementation of matplotlib function from matplotlib.artist import Artist import matplotlib.pyplot as plt import numpy as np from matplotlib.collections import EllipseCollection x = np.arange(10) y = np.arange(15) X, Y = np.meshgrid(x, y) XY = np.column_stack((X.ravel(), Y.ravel())) fig, ax = plt.subplots() ec = EllipseCollection(10, 10, 5, units ='y', offsets = XY * 0.5, transOffset = ax.transData, cmap ="bone") ec.set_array((X * Y + X * X).ravel()) ax.add_collection(ec) ax.autoscale_view() ax.set_xlabel('X') ax.set_ylabel('y') cbar = plt.colorbar(ec) cbar.set_label('X + Y') fig.suptitle("""matplotlib.artist.Artist.set_label() function Example""", fontweight="bold") plt.show() Output: Example 2: python3 # Implementation of matplotlib function from matplotlib.artist import Artist import matplotlib.pyplot as plt import numpy as np np.random.seed(19680801) n = 100000 x = np.random.standard_normal(n) y = 2 * np.random.standard_normal(n) z =[1, 2, 3, 4] xmin = x.min() xmax = x.max() ymin = y.min() ymax = y.max() fig, ax = plt.subplots() hb = ax.hexbin(x, y, gridsize = 50, bins ='log', cmap ='PuBuGn') ax.set(xlim =(xmin, xmax), ylim =(ymin, ymax)) cb = fig.colorbar(hb, ax = ax) cb.set_label('log') fig.suptitle("""matplotlib.artist.Artist.set_label() function Example""", fontweight="bold") plt.show() Output: Comment More infoAdvertise with us Next Article Matplotlib.artist.Artist.set_url() in Python S shivanisinghss2110 Follow Improve Article Tags : Python Python-matplotlib Matplotlib Artist-class Practice Tags : python Similar Reads Matplotlib.artist.Artist.set() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Artist class contains Abstract base class for objects that render into a FigureCanvas. All visible elements in a figure are subclasses of Artist. matplotlib.artist.Artist.set() method The set() meth 2 min read Matplotlib.artist.Artist.get_label() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Artist class contains Abstract base class for objects that render into a FigureCanvas. All visible elements in a figure are subclasses of Artist. Matplotlib.artist.Artist.get_label() Method The set_ 2 min read Matplotlib.artist.Artist.set_gid() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Artist class contains Abstract base class for objects that render into a FigureCanvas. All visible elements in a figure are subclasses of Artist. Matplotlib.artist.Artist.set_gid() Method The set_gi 2 min read Matplotlib.artist.Artist.set_url() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Artist class contains Abstract base class for objects that render into a FigureCanvas. All visible elements in a figure are subclasses of Artist. Matplotlib.artist.Artist.set_url() Method The set_ur 2 min read Matplotlib.artist.Artist.set_snap() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Artist class contains Abstract base class for objects that render into a FigureCanvas. All visible elements in a figure are subclasses of Artist. matplotlib.artist.Artist.set_snap() method The set_s 2 min read Matplotlib.axes.Axes.set_label() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Like