Matplotlib是Python中的一個庫,它是數字的-NumPy庫的數學擴展。它是Python中令人驚歎的可視化庫,用於數組的2D圖,並用於與更廣泛的SciPy堆棧配合使用。
Matplotlib.axis.Axis.get_transform()函數
matplotlib庫的axis模塊中的Axis.get_transform()函數用於獲取此美術師使用的Transform實例。
用法: Axis.get_transform(self)
參數:此方法不接受任何參數。
返回值:此方法返回此藝術家使用的Transform實例。
以下示例說明了matplotlib.axis中的matplotlib.axis.Axis.get_transform()函數:
範例1:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
fig, ax = plt.subplots()
l1, = ax.plot([0.1, 0.5, 0.9],
[0.1, 0.9, 0.5],
"bo-")
l2, = ax.plot([0.1, 0.5, 0.9],
[0.5, 0.2, 0.7],
"ro-")
for l in [l1, l2]:
xx = l.get_xdata()
yy = l.get_ydata()
shadow, = ax.plot(xx, yy)
shadow.update_from(l)
ot = mtransforms.offset_copy(l.get_transform(),
ax.figure,
x = 4.0, y =-6.0,
units ='points')
shadow.set_transform(ot)
fig.suptitle("""matplotlib.axis.Axis.get_transform()
function Example\n""", fontweight ="bold")
plt.show()
輸出:
範例2:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
from matplotlib import collections, colors, transforms
import numpy as np
nverts = 50
npts = 100
r = np.arange(nverts)
theta = np.linspace(0, 2 * np.pi, nverts)
xx = r * np.sin(theta)
yy = r * np.cos(theta)
spiral = np.column_stack([xx, yy])
rs = np.random.RandomState(19680801)
xyo = rs.randn(npts, 2)
colors = [colors.to_rgba(c)
for c in plt.rcParams['axes.prop_cycle'].by_key()['color']]
fig, ax1 = plt.subplots()
col = collections.RegularPolyCollection(
7, sizes = np.abs(xx) * 10.0,
offsets = xyo,
transOffset = ax1.transData)
trans = transforms.Affine2D().scale(fig.dpi / 72.0)
Axis.set_transform(col, trans)
ax1.add_collection(col, autolim = True)
col.set_color(colors)
print("Value Return by get_transform():\n",
col.get_transform())
fig.suptitle("""matplotlib.axis.Axis.get_transform()
function Example\n""", fontweight ="bold")
plt.show()
輸出:
相關用法
- Python Wand function()用法及代碼示例
- Python hex()用法及代碼示例
- Python now()用法及代碼示例
- Python oct()用法及代碼示例
- Python int()用法及代碼示例
- Python id()用法及代碼示例
- Python tell()用法及代碼示例
- Python sum()用法及代碼示例
- Python ord()用法及代碼示例
- Python str()用法及代碼示例
- Python cmp()用法及代碼示例
- Python dir()用法及代碼示例
- Python map()用法及代碼示例
- Python fmod()用法及代碼示例
- Python globals()用法及代碼示例
- Python ldexp()用法及代碼示例
注:本文由純淨天空篩選整理自SHUBHAMSINGH10大神的英文原創作品 Matplotlib.axis.Axis.get_transform() function in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。