setp函数--Matplotlib
生活随笔
收集整理的這篇文章主要介紹了
setp函数--Matplotlib
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
函數(shù)功能:
Set a property on an artist object.
設(shè)置元素屬性
函數(shù)語法:
setp(obj, *args, **kwargs)
函數(shù)參數(shù):
obj: 要設(shè)置的對象
matplotlib 支持使用setp()函數(shù)設(shè)置屬性,使用getp()函數(shù)獲取查看屬性,以及進(jìn)行自查。
例如要將線條風(fēng)格設(shè)置為虛線,可以:
line, = plot([1,2,3]) setp(line, linestyle='--') import matplotlib.pyplot as plt import numpy as npx = np.linspace(-2*np.pi, 2 * np.pi, 200) y = np.sin(x)line1,=plt.plot(x,y)plt.setp(line1,ls='--')plt.show()如果您想知道參數(shù)有效的類型(可取的值),則可以提供要設(shè)置的屬性名稱,但不帶值。
例如:獲取線條風(fēng)格的取值有哪些
import matplotlib.pyplot as plt import numpy as npx = np.linspace(-2*np.pi, 2 * np.pi, 200) y = np.sin(x)line,=plt.plot(x,y)plt.setp(line,'linestyle')運(yùn)行結(jié)果
3. If you want to see all the properties that can be set, and their possible values, you can do:
如果你想要查看所有可以設(shè)置的屬性和屬性的取值,可以:
運(yùn)行結(jié)果如下:
agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) arrayalpha: float or Noneanimated: boolantialiased or aa: boolclip_box: `.Bbox`clip_on: boolclip_path: Patch or (Path, Transform) or Nonecolor or c: colorcontains: unknowndash_capstyle: {'butt', 'round', 'projecting'}dash_joinstyle: {'miter', 'round', 'bevel'}dashes: sequence of floats (on/off ink in points) or (None, None)data: (2, N) array or two 1D arraysdrawstyle or ds: {'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'figure: `.Figure`fillstyle: {'full', 'left', 'right', 'bottom', 'top', 'none'}gid: strin_layout: boollabel: objectlinestyle or ls: {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}linewidth or lw: floatmarker: marker style string, `~.path.Path` or `~.markers.MarkerStyle`markeredgecolor or mec: colormarkeredgewidth or mew: floatmarkerfacecolor or mfc: colormarkerfacecoloralt or mfcalt: colormarkersize or ms: floatmarkevery: None or int or (int, int) or slice or List[int] or float or (float, float) or List[bool]path_effects: `.AbstractPathEffect`picker: unknownpickradius: floatrasterized: bool or Nonesketch_params: (scale: float, length: float, randomness: float)snap: bool or Nonesolid_capstyle: {'butt', 'round', 'projecting'}solid_joinstyle: {'miter', 'round', 'bevel'}transform: `matplotlib.transforms.Transform`url: strvisible: boolxdata: 1D arrayydata: 1D arrayzorder: floatProcess finished with exit code 0官方文檔: setp函數(shù)
總結(jié)
以上是生活随笔為你收集整理的setp函数--Matplotlib的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何搭建https代理?
- 下一篇: JVM面试专题