matplotlib contourf colorbar放到下方_matplotlib基础(入门)

本文介绍了使用Python的matplotlib库进行基础绘图,包括绘制线条、定制风格的多图、改变坐标轴形式、添加图例、注解、散点图、柱状图、等高线图、打印2D图像、subplot多合一显示、分格显示、图中图以及次坐标轴的用法。这些功能使matplotlib能替代matlab完成大部分基础绘图任务。
摘要由CSDN通过智能技术生成

ec5578b79ad4d0525193247325174e9c.png

为什么有些人说matlab被禁影响没有那么大

因为大部分基础绘图Python中的matplotlib模块完美胜任

1.draw a line

import matplotlib.pyplot as plt #use pyplot to draw
import numpy as np #admin
x=np.linspace(-1,1,50)#random points np.linspace(range1,range2,number)
y=2*x+1
plt.plot(x,y)
plt.show()#draw

0e503f763fd96706bdf7caf36e2bbb1f.png

2.draw multiple figures with customized style

import matplotlib.pyplot as plt
import numpy as np
x=np.linspace(-3,3,50)
y1=2*x+1
y2=x**2




plt.figure()#draw the first figure
plt.plot(x,y1)




plt.figure(num="fucking name",figsize=(8,5))#num=define the title of the figure
plt.plot(x,y2)#draw the second figure
plt.plot(x,y1,color="red",linewidth=5.0,linestyle="--")#draw two lines in figure"fucking name"


plt.show

282ee6afb9d9732b4c67abb3ff4b17bf.png

3.改变坐标轴的形式 并画图例( upperleft upper right lower right/left best 都是地址)

plt.plot(x,y2,label="up")#draw the second figure
plt.plot(x,y1,color="red",linewidth=5.0,linestyle="--",label="down")#draw two lines in figure"fucking name"
plt.legend(handles=[],labels=[],loc="best")#打出图例

cd1b5a53d78ad13306b8496e24403b9a.png

4.add annotation添加注解

plt.annotate(r"$你想要的名字%s$"%y0,xy=(x
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值