Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Matplotlib.artist.Artist.format_cursor_data() in Python

  • Last Updated : 10 May, 2020

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.format_cursor_data() method

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

The format_cursor_data() method in artist module of matplotlib library is used to get a string representation of data.

Syntax: Artist.remove_callback(self, data)



Parameters: This method accepts the following parameters.

  • data: This parameter is the data which is used to be used.

Returns: This method returns the string representation of data.

Below examples illustrate the matplotlib.artist.Artist.format_cursor_data() function in matplotlib:

Example 1:




# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.artist import Artist
       
  
np.random.seed(10**7)
geeksx = np.random.randn(10)
   
fig, ax = plt.subplots()
ax.plot(geeksx)
   
ax.text(1.5, 0.85
        "Value return by format_cursor_data():"
        fontweight ="bold")
   
ax.text(0, 0.7,
        Artist.format_cursor_data(ax, data = geeksx))
         
fig.suptitle('matplotlib.artist.Artist.format_cursor_data()\
function Example', fontweight ="bold"
  
plt.show()

Output:

Example 2:




# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.artist import Artist
        
  
geeksx = np.array([24.40, 110.25, 20.05,
                   22.00, 61.90, 7.80,
                   15.00])
       
fig, ax = plt.subplots()
ax.plot(geeksx, 'go-')
    
ax.text(1, 95,
        "Value return by format_cursor_data():",
        fontweight ="bold")
  
ax.text(1.3, 85,
        Artist.format_cursor_data(ax,
                                  data = geeksx))
          
fig.suptitle('matplotlib.artist.Artist.format_cursor_data()\
function Example', fontweight ="bold"
  
plt.show()

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!