【无标题】

画图相关

plotstem

Explanations

def plotstem(X,Y,label=None,smooth=False,h=False)
parammeaningtype
Xlist of X-axisArray, Dataframe (1- dimension)
Ylist of Y-axisArray, Dataframe ( 1- dimension)
labellist of labelsList, Arrary, Dataframe (1- dimension)
smoothWhether smoothing curveTrue or False (Default: False)
hWhether horizontalTrue of False (Default: False)

Examples

fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(5,8),dpi=200)

X = [[1,2,3,4,5,6,7,8,9,10]]    
Y = np.random.uniform(0,100,size=(2,10))  
plotstem(X,Y,ax1)    
plotstem(X,Y,ax2,smooth=True)    
plotstem(X,Y,ax3,smooth=True,h=True) 

Result

plotfilling

Explanations

def plotfilling(X,Y,ax,color=None)
parammeaningtype
Xlist of X-axisArray, Dataframe (1- dimension)
Ylist of Y-axisArray, Dataframe ( at most 2- dimensions)
colorlist of colorsArray, Dataframe (default)

Examples

fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(5,8),dpi=200)
ax1.spines["left"].set_visible(False)
ax1.spines["top"].set_visible(False)
ax1.spines["right"].set_visible(False)
ax.grid(ls = "--", lw = 0.25, color = "#4E616C")                
X = [[1,2,3,4,5,6,7,8,9,10]]
    
Y = np.random.uniform(0,100,size=(2,10))  

plotfilling(X,Y,ax1,color=['red','black'])
plotfilling(X,[Y[0]],ax2,color)
plotfilling(X,[Y[1]],ax3,color)

在这里插入图片描述

plotlines

Explanations

parammeaningtype
Xlist of X-axisArray, Dataframe (1- dimension)
Ylist of Y-axisArray, Dataframe ( n- dimensions)
colorlist of colorsArray, Dataframe
labellist of labelsList, Arrary, Dataframe (1- dimension)
linestylestylesReferred to linestyle in matplotlib
markermarkersReferred to marker in matplotlib
mfccolors of markerReferred to mfc in matplotlib
mssize of markersReferred to ms in matplotlib
smoothWhether smoothing curveTrue or False (Default: False)

Examples

fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(5,8),dpi=200)
X = [[1,2,3,4,5,6,7,8,9,10],
    [1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5]]
error=np.random.uniform(0,2,size=(2,10))
Y = np.random.uniform(0,100,size=(2,10))
plotlines(X,Y,ax1,color=['black','red'])
plotlines(X,Y,ax2,color=['black','red','pink','gray','yellow'],smooth=True)
plotlines(X,Y,ax3,linestyle='-',
          marker = 'o', mfc = 'white', ms = 4, smooth = False)      

plotstackedbar

Explanations

def plotstackbar(results,ax,category_names,hatch = None,indict_numbers=True,color=None,text_color = 'white', legendsize=8,frameon=True, width = 0.5,h=True,edgecolor='black',error=None):
parammeaningtype
resultslabels and values of each barDict (Default: None)
category_nameslabels of bar componentsArray, Dataframe (1- dimension)
hatchlist of hatchesArrary, Dataframe (1- dimension) (Default: None)
indict_numberswhehter or not indcict bar numbersTrue or False
colorcolors of each bar componentsArrary, Dataframe (1- dimension)(Default: None)
legendsizesize of legendDefault 8
frameonWhether to show the legend border or notTrue or False (Default: True)
widthwidth of each barDefault: 0.5
hWhether horizontalor notDefault: True
edgecolorcolor of edgeDefault: ‘black’
errorerror listDefault: None
category_names = ['Strongly disagree', 'Disagree',
                  'Neither agree nor disagree', 'Agree', 'Strongly agree']

results = {
    'Question 1': [10, 15, 17, 32, 26],
    'Question 2': [26, 22, 29, 10, 13],
    'Question 3': [35, 37, 7, 2, 19],
    'Question 4': [32, 11, 9, 15, 33],
    'Question 5': [21, 29, 5, 5, 40],
    'Question 6': [8, 19, 5, 30, 38]
}

fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(8,15),dpi=200)

hatch=['x','+','*','|','-']

plotstackbar(results, ax=ax1,category_names=category_names,text_color='darkgrey')
plotstackbar(results, ax=ax2,category_names=category_names,color = ['#f4b183','#ffd966','#c5e0b4', '#bdd7ee','#8dd3c7'],
             indict_numbers=False,text_color='darkgrey',frameon=False,h=False)
plotstackbar(results, ax=ax3,category_names=category_names,color = ['#f4b183','#ffd966','#c5e0b4', '#bdd7ee','#8dd3c7'],
             hatch=hatch,h=True)

plt.show()


在这里插入图片描述

heatmap && annotated_heatmap

Explanations

def heatmap(data, row_labels, col_labels, ax=None,
            cbar_kw=None, cbarlabel="", **kwargs)
            
def annotate_heatmap(im, data=None, valfmt="{x:.2f}",
                     textcolors=("black", "white"),
                     threshold=None, **textkw)
parammeaningtype
dataarrayarray(N-dimensions)
row_labelslabels of rowsarray(1-dimension)
col_labelslabels of columnsarray(N-dimensions)
cbar_kwcolorbar
cbarlabellabel for the colorbar

Examples

fig, ax = plt.subplots()

im, cbar = heatmap(harvest, vegetables, farmers, ax=ax,
cmap=“YlGn”, cbarlabel=“harvest [t/year]”)
texts = annotate_heatmap(im, valfmt=“{x:.1f} t”)

fig.tight_layout()
plt.show()
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

武汉大学计算机学院智能计算系统实验室

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值