Wednesday, December 25, 2024
Google search engine
HomeLanguagesMatplotlib.artist.Artist.get_sketch_params() in Python

Matplotlib.artist.Artist.get_sketch_params() 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_sketch_params() method

The get_sketch_params() method in artist module of matplotlib library is used to get the sketch parameters for the artist.

Syntax: Artist.get_sketch_params(self)

Parameters: This method does not accepts any parameter.

Returns: This method return the sketch parameters for the artist.

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

Example 1:




# Implementation of matplotlib function
from matplotlib.artist import Artistย ย 
import matplotlib.pyplot as pltย 
import matplotlib.colors as mcolorsย 
import matplotlib.gridspec as gridspecย 
import numpy as npย 
ย ย ย ย ย ย ย 
ย ย ย ย ย ย ย 
plt.rcParams['savefig.facecolor'] = "0.8"
plt.rcParams['figure.figsize'] = 6, 5
ย ย ย ย ย ย ย 
fig, ax = plt.subplots()ย 
ย ย ย ย ย ย ย 
ax.plot([1, 2])ย 
ย ย ย ย ย ย ย 
ax.locator_params("x", nbins = 3)ย 
ax.locator_params("y", nbins = 5)ย 
ย ย ย ย ย ย ย 
ax.set_xlabel('x-label')ย 
ax.set_ylabel('y-label')ย 
ย ย ย ย ย 
ax.text(0.2, 1.8, "Sketch Parameters : "
ย ย ย ย ย ย ย ย +str(Artist.get_sketch_params(ax)),ย ย 
ย ย ย ย ย ย ย ย fontweight ="bold")ย ย 
ย ย 
fig.suptitle('matplotlib.artist.Artist.get_sketch_params()\
function Example', fontweight ="bold")ย 
ย ย 
plt.show()


Output:

Example 2:




# Implementation of matplotlib function
from matplotlib.artist import Artistย ย 
import matplotlib.pyplot as pltย 
import numpy as npย 
ย ย ย ย ย ย 
values = np.array([ย 
ย ย ย ย 0.015, 0.166, 0.133,ย 
ย ย ย ย 0.159, 0.041, 0.024,ย 
ย ย ย ย 0.195, 0.039, 0.161,ย 
ย ย ย ย 0.018, 0.143, 0.056,ย 
ย ย ย ย 0.125, 0.096, 0.094,ย 
ย ย ย ย 0.051, 0.043, 0.021,ย 
ย ย ย ย 0.138, 0.075, 0.109,ย 
ย ย ย ย 0.195, 0.050, 0.074,ย 
ย ย ย ย 0.079, 0.155, 0.020,ย 
ย ย ย ย 0.010, 0.061, 0.008])ย 
ย ย ย ย ย ย 
values[[3, 14]] += .8
ย ย ย ย ย ย 
fig, (ax, ax2) = plt.subplots(2, 1,ย 
ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย sharex = True)ย 
ย ย ย ย ย ย 
ax.plot(values, "o-", color ="green")ย 
ax2.plot(values, "o-", color ="green")ย 
ย ย ย ย ย ย 
ax.set_ylim(.78, 1.)ย ย 
ax2.set_ylim(0, .22)ย 
ย ย ย ย ย ย 
ax.spines['bottom'].set_visible(False)ย 
ax2.spines['top'].set_visible(False)ย 
ย ย ย ย 
ax.xaxis.tick_top()ย 
ax.tick_params(labeltop = False)ย 
ax2.xaxis.tick_bottom()ย 
ย ย ย ย ย ย 
d = .005
kwargs = dict(transform = ax.transAxes,ย ย 
ย ย ย ย ย ย ย ย ย ย ย ย ย ย color ='k',ย ย 
ย ย ย ย ย ย ย ย ย ย ย ย ย ย clip_on = False)ย 
ย ย ย ย 
ax.plot((-d, +d), (-d, +d), **kwargs)ย ย ย ย ย ย ย ย 
ax.plot((1 - d, 1 + d), (-d, +d), **kwargs)ย ย 
ย ย ย ย ย ย 
kwargs.update(transform = ax2.transAxes)ย ย ย 
ax2.plot((-d, +d), (1 - d, 1 + d), **kwargs)ย 
ax2.plot((1 - d, 1 + d), (1 - d, 1 + d), **kwargs)ย ย 
ย ย 
Artist.set_sketch_params(ax, 1.0, 100.0, 22.0)ย 
Artist.set_sketch_params(ax2, 1.0, 10.0, 22.0)
ย ย ย ย ย 
ax.text(5, .95, "Sketch Parameters : "
ย ย ย ย ย ย ย ย + str(Artist.get_sketch_params(ax)),ย ย 
ย ย ย ย ย ย ย ย fontweight ="bold")ย ย 
ย ย 
fig.suptitle('matplotlib.artist.Artist.get_sketch_params()\
function Example', fontweight ="bold")ย 
ย ย 
plt.show()


Output:

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments

๊ฐ•์„œ๊ตฌ์ถœ์žฅ๋งˆ์‚ฌ์ง€ on How to store XML data into a MySQL database using Python?
๊ธˆ์ฒœ๊ตฌ์ถœ์žฅ๋งˆ์‚ฌ์ง€ on How to store XML data into a MySQL database using Python?
๊ด‘๋ช…์ถœ์žฅ์•ˆ๋งˆ on How to store XML data into a MySQL database using Python?
๊ด‘๋ช…์ถœ์žฅ์•ˆ๋งˆ on How to store XML data into a MySQL database using Python?
์ถœ์žฅ์˜คํ”ผ on How to store XML data into a MySQL database using Python?
๋ถ€์ฒœ์ถœ์žฅ์•ˆ๋งˆ on How to store XML data into a MySQL database using Python?
๊ตฌ์›”๋™์ถœ์žฅ์•ˆ๋งˆ on How to store XML data into a MySQL database using Python?
๊ฐ•์„œ๊ตฌ์ถœ์žฅ์•ˆ๋งˆ on How to store XML data into a MySQL database using Python?
ํ—ฌ๋กœ์ถœ์žฅ on How to store XML data into a MySQL database using Python?
์˜ค์‚ฐ์ถœ์žฅ์•ˆ๋งˆ on How to store XML data into a MySQL database using Python?
๊ด‘๋ช…์ถœ์žฅ๋งˆ์‚ฌ์ง€ on How to store XML data into a MySQL database using Python?
๋งˆํฌ์ถœ์žฅ on How to store XML data into a MySQL database using Python?
์•ˆ์–‘์ถœ์žฅ๋งˆ์‚ฌ์ง€ on How to store XML data into a MySQL database using Python?
๋ถ€์ฒœ์ถœ์žฅ์•ˆ๋งˆ on How to store XML data into a MySQL database using Python?
๋™ํƒ„์ถœ์žฅ์•ˆ๋งˆ on How to store XML data into a MySQL database using Python?
์„œ์šธ์ถœ์žฅ์•ˆ๋งˆ on How to store XML data into a MySQL database using Python?
๋ถ„๋‹น์ถœ์žฅ์•ˆ๋งˆ on How to store XML data into a MySQL database using Python?
๋ถ€์ฒœ์ถœ์žฅ์•ˆ๋งˆ on How to store XML data into a MySQL database using Python?
์ถœ์žฅ ์˜คํ”ผ on How to store XML data into a MySQL database using Python?
ํ™”๊ณก๋™์ถœ์žฅ๋งˆ์‚ฌ์ง€ on How to store XML data into a MySQL database using Python?
๊ฐ•์„œ๊ตฌ์ถœ์žฅ๋งˆ์‚ฌ์ง€ on How to store XML data into a MySQL database using Python?
๊ณ ์–‘์ถœ์žฅ์•ˆ๋งˆ on How to store XML data into a MySQL database using Python?
ํ™”์„ฑ์ถœ์žฅ๋งˆ์‚ฌ์ง€ on How to store XML data into a MySQL database using Python?
์ฒœํ˜ธ๋™์ถœ์žฅ๋งˆ์‚ฌ์ง€ on How to store XML data into a MySQL database using Python?