国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python+matplotlib繪制餅圖散點圖實例代碼

2020-01-04 16:10:45
字體:
來源:轉載
供稿:網友

本文是從python/286318.html">python/288268.html">matplotlib官網上摘錄下來的一個實例,實現的功能是Python+matplotlib繪制自定義餅圖作為散點圖的標記,具體如下。

首先看下演示效果

python,matplotlib,散點圖,matplotlib繪制散點圖,matplotlib畫散點圖,matplotlib散點圖顏色

實例代碼:

import numpy as npimport matplotlib.pyplot as plt# first define the ratiosr1 = 0.2    # 20%r2 = r1 + 0.4 # 40%# define some sizes of the scatter markersizes = np.array([60, 80, 120])# calculate the points of the first pie marker## these are just the origin (0,0) +# some points on a circle cos,sinx = [0] + np.cos(np.linspace(0, 2 * np.pi * r1, 10)).tolist()y = [0] + np.sin(np.linspace(0, 2 * np.pi * r1, 10)).tolist()xy1 = list(zip(x, y))s1 = np.max(xy1)x = [0] + np.cos(np.linspace(2 * np.pi * r1, 2 * np.pi * r2, 10)).tolist()y = [0] + np.sin(np.linspace(2 * np.pi * r1, 2 * np.pi * r2, 10)).tolist()xy2 = list(zip(x, y))s2 = np.max(xy2)x = [0] + np.cos(np.linspace(2 * np.pi * r2, 2 * np.pi, 10)).tolist()y = [0] + np.sin(np.linspace(2 * np.pi * r2, 2 * np.pi, 10)).tolist()xy3 = list(zip(x, y))s3 = np.max(xy3)fig, ax = plt.subplots()ax.scatter(range(3), range(3), marker=(xy1, 0),      s=s1 ** 2 * sizes, facecolor='blue')ax.scatter(range(3), range(3), marker=(xy2, 0),      s=s2 ** 2 * sizes, facecolor='green')ax.scatter(range(3), range(3), marker=(xy3, 0),      s=s3 ** 2 * sizes, facecolor='red')plt.show()

總結

以上就是本文關于python+matplotlib繪制餅圖散點圖實例代碼的全部內容,希望對大家有所幫助。感興趣的朋友可以繼續參閱本站其他相關專題,如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!


注:相關教程知識閱讀請移步到python教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 邯郸县| 靖宇县| 金沙县| 霸州市| 浮山县| 沙河市| 招远市| 乐业县| 英山县| 沧源| 大厂| 班玛县| 石柱| 临潭县| 香河县| 中卫市| 汉寿县| 保康县| 龙海市| 满洲里市| 凌源市| 铁力市| 永顺县| 泰兴市| 大厂| 兴化市| 岳普湖县| 淮阳县| 宣汉县| 灵台县| 呼和浩特市| 含山县| 四会市| 都匀市| 张掖市| 达尔| 建湖县| 银川市| 永州市| 绵竹市| 南陵县|