最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python+matplotlib繪制簡單的海豚(頂點(diǎn)和節(jié)點(diǎn)的操作)

 更新時(shí)間:2018年01月02日 10:14:25   投稿:mengwei  
這篇文章主要介紹了python+matplotlib繪制簡單的海豚(頂點(diǎn)和節(jié)點(diǎn)的操作),具有一定借鑒價(jià)值,需要的朋友可以參考下

海豚

本文例子主要展示了如何使用補(bǔ)丁、路徑和轉(zhuǎn)換類繪制和操作給定的頂點(diǎn)和節(jié)點(diǎn)的形狀。

測試可用。

import matplotlib.cm as cm
import matplotlib.pyplot as plt
from matplotlib.patches import Circle, PathPatch
from matplotlib.path import Path
from matplotlib.transforms import Affine2D
import numpy as np

# Fixing random state for reproducibility
np.random.seed(19680801)


r = np.random.rand(50)
t = np.random.rand(50) * np.pi * 2.0
x = r * np.cos(t)
y = r * np.sin(t)

fig, ax = plt.subplots(figsize=(6, 6))
circle = Circle((0, 0), 1, facecolor='none',
        edgecolor=(0, 0.8, 0.8), linewidth=3, alpha=0.5)
ax.add_patch(circle)

im = plt.imshow(np.random.random((100, 100)),
        origin='lower', cmap=cm.winter,
        interpolation='spline36',
        extent=([-1, 1, -1, 1]))
im.set_clip_path(circle)

plt.plot(x, y, 'o', color=(0.9, 0.9, 1.0), alpha=0.8)

# Dolphin from OpenClipart library by Andy Fitzsimon
#    <cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
#     <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
#     <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
#     <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
#    </cc:License>

dolphin = """
M -0.59739425,160.18173 C -0.62740401,160.18885 -0.57867129,160.11183
-0.57867129,160.11183 C -0.57867129,160.11183 -0.5438361,159.89315
-0.39514638,159.81496 C -0.24645668,159.73678 -0.18316813,159.71981
-0.18316813,159.71981 C -0.18316813,159.71981 -0.10322971,159.58124
-0.057804323,159.58725 C -0.029723983,159.58913 -0.061841603,159.60356
-0.071265813,159.62815 C -0.080250183,159.65325 -0.082918513,159.70554
-0.061841203,159.71248 C -0.040763903,159.7194 -0.0066711426,159.71091
0.077336307,159.73612 C 0.16879567,159.76377 0.28380306,159.86448
0.31516668,159.91533 C 0.3465303,159.96618 0.5011127,160.1771
0.5011127,160.1771 C 0.63668998,160.19238 0.67763022,160.31259
0.66556395,160.32668 C 0.65339985,160.34212 0.66350443,160.33642
0.64907098,160.33088 C 0.63463742,160.32533 0.61309688,160.297
0.5789627,160.29339 C 0.54348657,160.28968 0.52329693,160.27674
0.50728856,160.27737 C 0.49060916,160.27795 0.48965803,160.31565
0.46114204,160.33673 C 0.43329696,160.35786 0.4570711,160.39871
0.43309565,160.40685 C 0.4105108,160.41442 0.39416631,160.33027
0.3954995,160.2935 C 0.39683269,160.25672 0.43807996,160.21522
0.44567915,160.19734 C 0.45327833,160.17946 0.27946869,159.9424
-0.061852613,159.99845 C -0.083965233,160.0427 -0.26176109,160.06683
-0.26176109,160.06683 C -0.30127962,160.07028 -0.21167141,160.09731
-0.24649368,160.1011 C -0.32642366,160.11569 -0.34521187,160.06895
-0.40622293,160.0819 C -0.467234,160.09485 -0.56738444,160.17461
-0.59739425,160.18173
"""

vertices = []
codes = []
parts = dolphin.split()
i = 0
code_map = {
  'M': (Path.MOVETO, 1),
  'C': (Path.CURVE4, 3),
  'L': (Path.LINETO, 1)}

while i < len(parts):
  code = parts[i]
  path_code, npoints = code_map[code]
  codes.extend([path_code] * npoints)
  vertices.extend([[float(x) for x in y.split(',')] for y in
           parts[i + 1:i + npoints + 1]])
  i += npoints + 1
vertices = np.array(vertices, float)
vertices[:, 1] -= 160

dolphin_path = Path(vertices, codes)
dolphin_patch = PathPatch(dolphin_path, facecolor=(0.6, 0.6, 0.6),
             edgecolor=(0.0, 0.0, 0.0))
ax.add_patch(dolphin_patch)

vertices = Affine2D().rotate_deg(60).transform(vertices)
dolphin_path2 = Path(vertices, codes)
dolphin_patch2 = PathPatch(dolphin_path2, facecolor=(0.5, 0.5, 0.5),
              edgecolor=(0.0, 0.0, 0.0))
ax.add_patch(dolphin_patch2)

plt.show()

效果如下:

總結(jié)

以上就是本文關(guān)于python+matplotlib繪制簡單的海豚(頂點(diǎn)和節(jié)點(diǎn)的操作)的全部內(nèi)容,希望對(duì)大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站其他相關(guān)專題,如有不足之處,歡迎留言指出。感謝朋友們對(duì)本站的支持!

相關(guān)文章

  • Python入門篇之文件

    Python入門篇之文件

    文件是我們儲(chǔ)存信息的地方,我們經(jīng)常要對(duì)文件進(jìn)行讀、寫、刪除等的操作,在Python中,我們可用Python提供的函數(shù)和方法方便地操作文件。文件可以通過調(diào)用open或file來打開,open通常比file更通用,因?yàn)閒ile幾乎都是為面向?qū)ο蟪绦蛟O(shè)計(jì)量身打造
    2014-10-10
  • python中open函數(shù)的基本用法示例

    python中open函數(shù)的基本用法示例

    這篇文章主要給大家介紹了關(guān)于python中open函數(shù)的基本用法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用python具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • 使用Python實(shí)現(xiàn)屏幕截圖工具

    使用Python實(shí)現(xiàn)屏幕截圖工具

    這篇文章主要為大家詳細(xì)介紹了如何使用Python實(shí)現(xiàn)一個(gè)簡單的屏幕截圖工具,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2025-03-03
  • 使用Python實(shí)現(xiàn)輕松調(diào)整視頻的播放速度

    使用Python實(shí)現(xiàn)輕松調(diào)整視頻的播放速度

    這篇文章主要介紹了如何通過 moviepy.editor 中的 VideoFileClip 類和 fx.speedx 函數(shù)實(shí)現(xiàn)輕松地調(diào)整視頻的播放速度,感興趣的可以了解下
    2024-11-11
  • Python 2.7中文顯示與處理方法

    Python 2.7中文顯示與處理方法

    今天小編就為大家分享一篇Python 2.7中文顯示與處理方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-07-07
  • pytorch 如何用cuda處理數(shù)據(jù)

    pytorch 如何用cuda處理數(shù)據(jù)

    考慮到各種運(yùn)算只能在cpu或者gpu運(yùn)算,不能混和運(yùn)算,本文介紹常用的幾種把數(shù)據(jù)挪到gpu或者直接在gpu創(chuàng)建數(shù)據(jù)再進(jìn)行運(yùn)算的方法
    2021-06-06
  • Python管理Windows服務(wù)小腳本

    Python管理Windows服務(wù)小腳本

    這篇文章主要為大家詳細(xì)介紹了Python管理Windows服務(wù)的小腳本,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-03-03
  • Django瀑布流的實(shí)現(xiàn)示例

    Django瀑布流的實(shí)現(xiàn)示例

    在瀏覽一些網(wǎng)站時(shí),經(jīng)常會(huì)看到類似于這種滿屏都是圖片,本文主要介紹了Django瀑布流的實(shí)現(xiàn)示例,具有一定的參考價(jià)值,感興趣的可以了解一下
    2023-03-03
  • python bluetooth藍(lán)牙信息獲取藍(lán)牙設(shè)備類型的方法

    python bluetooth藍(lán)牙信息獲取藍(lán)牙設(shè)備類型的方法

    這篇文章主要介紹了python bluetooth藍(lán)牙信息獲取藍(lán)牙設(shè)備類型的方法,具體轉(zhuǎn)化方法文中給大家介紹的非常詳細(xì),非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-11-11
  • 用python批量移動(dòng)文件

    用python批量移動(dòng)文件

    這篇文章主要介紹了如何用python批量移動(dòng)文件,幫助大家更好的理解和使用python,感興趣的朋友可以了解下
    2021-01-01

最新評(píng)論

桂东县| 泾阳县| 松桃| 项城市| 郯城县| 永嘉县| 马公市| 谢通门县| 钟山县| 平顺县| 兖州市| 长治市| 吉首市| 延长县| 乌拉特后旗| 赤城县| 霍林郭勒市| 通化县| 芜湖市| 石门县| 宾阳县| 漠河县| 四平市| 苏尼特左旗| 依兰县| 盖州市| 浑源县| 肃南| 大余县| 滁州市| 西畴县| 临朐县| 镇宁| 威远县| 建瓯市| 洛川县| 瑞金市| 刚察县| 修文县| 辛集市| 汉寿县|