亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Python實(shí)現(xiàn)改變與矩形橡膠的線條的顏色代碼示例

 更新時(shí)間:2018年01月05日 08:41:41   投稿:mengwei  
這篇文章主要介紹了Python實(shí)現(xiàn)改變與矩形橡膠的線條的顏色代碼示例,具有一定借鑒價(jià)值,需要的朋友可以參考下

 與矩形相交的線條顏色為紅色,其他為藍(lán)色。

演示如下:

實(shí)例代碼如下:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.transforms import Bbox
from matplotlib.path import Path

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


left, bottom, width, height = (-1, -1, 2, 2)
rect = plt.Rectangle((left, bottom), width, height, facecolor="#aaaaaa")

fig, ax = plt.subplots()
ax.add_patch(rect)

bbox = Bbox.from_bounds(left, bottom, width, height)

for i in range(12):
  vertices = (np.random.random((2, 2)) - 0.5) * 6.0
  path = Path(vertices)
  if path.intersects_bbox(bbox):
    color = 'r'
  else:
    color = 'b'
  ax.plot(vertices[:, 0], vertices[:, 1], color=color)

plt.show()

腳本運(yùn)行時(shí)間:(0分0.026秒)

總結(jié)

以上就是本文關(guān)于Python實(shí)現(xiàn)改變與矩形橡膠的線條的顏色代碼示例的全部?jī)?nèi)容,希望對(duì)大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站:

Python竟能畫(huà)這么漂亮的花,帥呆了(代碼分享)

Python學(xué)習(xí)之用pygal畫(huà)世界地圖實(shí)例

Python matplotlib畫(huà)圖實(shí)例之繪制擁有彩條的圖表

如有不足之處,歡迎留言指出。感謝朋友們對(duì)本站的支持!

相關(guān)文章

最新評(píng)論