记录两个Matplotlib画图代码

第一个画图代码:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties

font = FontProperties(fname='C:\Windows\Fonts\simfang.ttf')

x = np.linspace(-2,2,100)
y = x**2
z = np.sqrt(4-x**2)

fix,ax = plt.subplots()
ax.plot(x,y,label="$y=x^2$",color="red",linewidth = 2)
ax.plot(x,z,label="&x^2+y^2=4$",linewidth = 2)
ax.plot(x,-z,label="$x^2+y^2=4$",linewidth = 2)

ax.set_title("线性图",fontsize = 24,fontproperties=font)
ax.set_xlabel("X轴",fontsize = 20,fontproperties=font)
ax.set_ylabel("Y轴",fontsize = 20,fontproperties=font)

plt.legend
plt.grid()
plt.show()

运行画出的图像为:


第二个画图代码:

import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.axisartist as axisartist

fig = plt.figure(figsize=(6,6))
ax = axisartist.Subplot(fig,111)
fig.add_axes(ax)
ax.axis[:].set_visible(False)
ax.axis['x'] = ax.new_floating_axis(0,0)
ax.axis['y'] = ax.new_floating_axis(1,0)
ax.axis['x'].set_axisline_style('-|>',size=1.0)
ax.axis['y'].set_axisline_style('-|>',size=1.0)
ax.axis['x'].set_axis_direction('top')
ax.axis['y'].set_axis_direction('right')
plt.xlim(-10,10)
plt.ylim(-0.1,1.2)
x = np.arange(-10,10,0.1)
y = 1/(1+np.exp(-x))
plt.plot(x,y,label=r"$sigmoid=\frac{1}{1+e^{-x}}$",c='r')
plt.legend()

运行画出的图像为:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值