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

歡迎訪問 生活随笔!

生活随笔

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

python

scatter 基本用法 python matplotlib

發布時間:2025/4/5 python 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 scatter 基本用法 python matplotlib 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

直接看注釋吧,知行合一!

# -*- coding: utf-8 -*- """ Created on Tue Mar 21 10:36:28 2017 羅干,同濟大學圖書館 我愛婷婷和臭臭@author: user """ #導入模塊 from matplotlib import pyplot as plt import numpy as np #定義兩個矩陣 A1=np.array([0,0]) B1=np.array(([2,0],[0,2])) #以 A1為均值,B1為協方差矩陣,生成正態分布的隨機數 C1=np.random.multivariate_normal(A1,B1,10) C2=np.random.multivariate_normal(A1+0.2,B1+0.2,10) #畫布的大小為長8cm高6cm plt.figure(figsize=(8,6)) #畫圖吧,s表示點點的大小,c就是color嘛,marker就是點點的形狀哦o,x,*><^,都可以啦 #alpha,點點的亮度,label,標簽啦 plt.scatter(C1[:,0],C1[:,1],s=30,c='red',marker='o',alpha=0.5,label='C1') plt.scatter(C2[:,0],C2[:,1],s=30,c='blue',marker='x',alpha=0.5,label='C2') #下面三行代碼很簡單啦 plt.title('basic scatter plot ') plt.xlabel('variables x') plt.ylabel('variables y')plt.legend(loc='upper right')#這個必須有,沒有你試試看plt.show()#這個可以沒有

import matplotlib.pyplot as pltx_coords = [0.13, 0.22, 0.39, 0.59, 0.68, 0.74, 0.93] y_coords = [0.75, 0.34, 0.44, 0.52, 0.80, 0.25, 0.55]fig = plt.figure(figsize=(8,5)) plt.scatter(x_coords, y_coords, marker='s', s=50)for x, y in zip(x_coords, y_coords):plt.annotate('(%s, %s)' %(x, y),xy=(x, y),xytext=(0, -10),textcoords='offset points',ha='center',va='top')plt.xlim([0,1]) plt.ylim([0,1]) plt.show()

import numpy as np import matplotlib.pyplot as pltfig = plt.figure(figsize=(8,6))# Generating a Gaussion dataset: # creating random vectors from the multivariate normal distribution # given mean and covariance mu_vec1 = np.array([0,0]) cov_mat1 = np.array([[1,0],[0,1]]) X = np.random.multivariate_normal(mu_vec1, cov_mat1, 500)R = X**2 R_sum = R.sum(axis=1) plt.scatter(X[:, 0], X[:, 1],color='gray',marker='o',s=32. * R_sum,edgecolor='black',alpha=0.5) plt.show()

轉載自斗大的熊貓

總結

以上是生活随笔為你收集整理的scatter 基本用法 python matplotlib的全部內容,希望文章能夠幫你解決所遇到的問題。

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