也許Excel滿足不了你的繪圖需求,也許R包安裝有些麻煩,那就用Python吧,簡(jiǎn)單繪制圖表。在此之前我們需要安裝一系列我們需要的第三庫
pip install matplotlib
pip install numpy
在繪制以下集中圖形的時(shí)候,我們需要引入第三庫
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
from matplotlib_venn import venn2,venn2_circles#venn圖
from matplotlib_venn import venn3,venn3_circles
至此,我們引入了需要的庫
#首先我們創(chuàng)建圖形
fig = plt.figure()
x = [1,3,5,7,9]
y = [x^2 for x in x ]
plt.scatter(x,y,c=None,s=20,alpha=0.3,cmap=None,marker='o')#繪制
plt.xlabel(’x')
plt.ylabel('y')
plt.title('picture')
plt.show()
如圖

image.png
接下來 我們創(chuàng)建venn圖
venn2(subsets(3,2,1),set_labels=('A','B')
venn2([set(['1','2','3','5']),set(['1','6','7'])])
如圖

image.png
當(dāng)然,也存在venn3繪制
set1 = set(['alex', 'li', 'kan', 'Dary'])#集合1
set2 = set(['Bob', 'kan', 'Dary', 'mart'])#集合2
set3 = set(['kan', 'Dary',' Elief', 'Fuck', 'Green'])#集合3
venn3([set1, set2, set3], ('Set1', 'Set2', 'Set3'))#繪圖交集
如圖

image.png
在學(xué)習(xí)和生活中,柱狀圖是經(jīng)常見到的圖表形式,因此,柱狀圖的繪制也必須學(xué)會(huì),
fig = plt.figure(figsize=(12,4))
x1 = [1,2,3,4]
y1 = [5,10,15,20]
plt.ylim(0,30)#長(zhǎng)度
plt.bar(x1,y1)#繪制
plt.xlabel('x')#標(biāo)簽
plt.ylabel('y')#標(biāo)簽
plt.title('title')#表頭
group_labels = ['a','b','c','d']#x軸可用文字表示
plt.xticks(x1,group_labels)
如圖

image.png
折線圖也是對(duì)于趨勢(shì)的表示也是很有用的
fig = plt.figure()
x = ['1','2','3','4']
y = ['2','4','6','4']
plt.xlabel('x')
plt.ylabel('y')
plt.title('title')
group_labels=['a','b','c','d']
plt.plot(x,y)
plt.xticks(x,group_labels,rotation=0)
plt.grid()#繪制折線圖
如圖

image.png
創(chuàng)建多圖
plt.figure()#建立圖片
plt.subplot(221)#建立兩行兩列 這是第一行第一列的相應(yīng)位置,
x = [1,3,5,7,9]
y = [x^2 for x in x ]
plt.scatter(x,y,c=None,s=20,alpha=0.3,cmap=None,marker='o')
plt.subplot(222)
plt.subplot(223)
x = [1,3,5,7,9]
y = [x for x in x ]
plt.scatter(x,y,c=None,s=20,alpha=0.3,cmap=None,marker='o')
plt.subplot(224)
如圖

image.png
以上便是簡(jiǎn)單的圖標(biāo)繪制的方法總結(jié)。