日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python绘图函数m_Python散点图。m的尺寸和样式

發布時間:2023/12/18 python 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python绘图函数m_Python散点图。m的尺寸和样式 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我想我們可以通過一系列補丁來做得更好。

根據文件:This (PatchCollection) makes it easier to assign a color map to a heterogeneous

collection of patches.

This also may improve plotting speed, since PatchCollection will

draw faster than a large number of patches.

假設要以數據單位繪制具有給定半徑的圓的散點圖:def circles(x, y, s, c='b', vmin=None, vmax=None, **kwargs):

"""

Make a scatter of circles plot of x vs y, where x and y are sequence

like objects of the same lengths. The size of circles are in data scale.

Parameters

----------

x,y : scalar or array_like, shape (n, )

Input data

s : scalar or array_like, shape (n, )

Radius of circle in data unit.

c : color or sequence of color, optional, default : 'b'

`c` can be a single color format string, or a sequence of color

specifications of length `N`, or a sequence of `N` numbers to be

mapped to colors using the `cmap` and `norm` specified via kwargs.

Note that `c` should not be a single numeric RGB or RGBA sequence

because that is indistinguishable from an array of values

to be colormapped. (If you insist, use `color` instead.)

`c` can be a 2-D array in which the rows are RGB or RGBA, however.

vmin, vmax : scalar, optional, default: None

`vmin` and `vmax` are used in conjunction with `norm` to normalize

luminance data. If either are `None`, the min and max of the

color array is used.

kwargs : `~matplotlib.collections.Collection` properties

Eg. alpha, edgecolor(ec), facecolor(fc), linewidth(lw), linestyle(ls),

norm, cmap, transform, etc.

Returns

-------

paths : `~matplotlib.collections.PathCollection`

Examples

--------

a = np.arange(11)

circles(a, a, a*0.2, c=a, alpha=0.5, edgecolor='none')

plt.colorbar()

License

--------

This code is under [The BSD 3-Clause License]

(http://opensource.org/licenses/BSD-3-Clause)

"""

import numpy as np

import matplotlib.pyplot as plt

from matplotlib.patches import Circle

from matplotlib.collections import PatchCollection

if np.isscalar(c):

kwargs.setdefault('color', c)

c = None

if 'fc' in kwargs: kwargs.setdefault('facecolor', kwargs.pop('fc'))

if 'ec' in kwargs: kwargs.setdefault('edgecolor', kwargs.pop('ec'))

if 'ls' in kwargs: kwargs.setdefault('linestyle', kwargs.pop('ls'))

if 'lw' in kwargs: kwargs.setdefault('linewidth', kwargs.pop('lw'))

patches = [Circle((x_, y_), s_) for x_, y_, s_ in np.broadcast(x, y, s)]

collection = PatchCollection(patches, **kwargs)

if c is not None:

collection.set_array(np.asarray(c))

collection.set_clim(vmin, vmax)

ax = plt.gca()

ax.add_collection(collection)

ax.autoscale_view()

if c is not None:

plt.sci(collection)

return collection

scatter函數的所有參數和關鍵字(除了marker)都將以類似的方式工作。

我寫了一個gist包括圓,橢圓和正方形/矩形。如果你想要一個其他形狀的集合,你可以自己修改它。

如果要繪制colorbar圖,只需運行colorbar(),或將返回的集合對象傳遞給colorbar函數。

例如:from pylab import *

figure(figsize=(6,4))

ax = subplot(aspect='equal')

#plot a set of circle

a = arange(11)

out = circles(a, a, a*0.2, c=a, alpha=0.5, ec='none')

colorbar()

#plot one circle (the lower-right one)

circles(1, 0, 0.4, 'r', ls='--', lw=5, fc='none', transform=ax.transAxes)

xlim(0,10)

ylim(0,10)

輸出:

總結

以上是生活随笔為你收集整理的python绘图函数m_Python散点图。m的尺寸和样式的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。