Matplotlib是Python中的一個庫,它是數字的-NumPy庫的數學擴展。的Artist類包含呈現對象的Abstract基類到一個FigureCanvas中。圖中所有可見元素都是Artist的子類。
Matplotlib.artist.Artist.set_url()方法
matplotlib庫的藝術家模塊中的set_url()方法用於設置藝術家的網址。
用法:Artist.set_url(self, url)
參數:此方法僅接受一個參數。
- 網址:此參數是包含URL的字符串。
返回值:此方法不返回任何值。
以下示例說明了matplotlib.artist.Artist。set_url()在matplotlib中的函數:
範例1:
# Implementation of matplotlib function
from matplotlib.artist import Artist
import numpy as np
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
f, ax = plt.subplots()
s = ax.scatter([1, 2, 3], [4, 5, 6])
Artist.set_url(s, 'http://www.google.com')
f.canvas.print_figure('geeks1.svg')
f.suptitle("""matplotlib.artist.Artist.set_url()
function Example""", fontweight="bold")
plt.show()
輸出:
範例2:
# Implementation of matplotlib function
from matplotlib.artist import Artist
import numpy as np
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
f, ax = plt.subplots()
delta = 0.025
x = y = np.arange(-3.0, 3.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = np.exp(-X**2 - Y**2)
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
Z = (Z1 - Z2) * 2
im = ax.imshow(Z,
interpolation ='bilinear',
cmap = "bone",
origin ='lower',
extent =[-3, 3, -3, 3])
Artist.set_url(im, 'https://www.geeksforgeeks.org/')
f.canvas.print_figure('geeks2.svg')
f.suptitle("""matplotlib.artist.Artist.set_url()
function Example""", fontweight="bold")
plt.show()
輸出:
相關用法
注:本文由純淨天空篩選整理自shivanisinghss2110大神的英文原創作品 Matplotlib.artist.Artist.set_url() in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。