Matplotlib自学打卡day1

写前声明

由于本人是自己在	matplotlib官网上自学的,所以可能会出现不准确的问题还请大家海涵。

画折线图

第一种方法(O, O, style)

import matplotlib.pyplot as plt
import pandas  
# this bag will not be used later but it's my habit to import it
import numpy as np


x = np.linspace(0, 2, 100)  # plot the x_axes into 100 ,and the  range is from 0 to 100
fig, ax = plt.subplots()  # create a coordinate system
ax.plot(x, x, label="linear")  # this is the formation of(O,O,style)
ax.plot(x, x**2, label="quadratic")
ax.plot(x, x**3, label="cubic")
# ax.plot(x, x**x, label='unkown')
ax.set_xlabel("x_label")  # plot 'x_label' to x_axes
ax.set_ylabel("y_label")
ax.set_title("multi-xy")
ax.legend()  # plot legend to this ax
plt.show()

第二种方法pyplot-style

import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2, 100)
plt.plot(x, x, label='linear')  # plot some data in the implicit axes
plt.plot(x, x**2, label='quadratic')
plt.plot(x, x**3, label='cubic')
plt.xlabel('x_label')
plt.ylabel('y_label')
plt.title('multi-xy')
plt.legend()
plt.show()

今天的最后一个知识点

import matplotlib.pyplot as plt
import pandas  # this bag will not be used later but it's my habit to import it
import numpy as np


def my_plotter(ax, data1, data2, param_dict):
    out = ax.plot(data1, data2, **param_dict)

    return out

data1, data2, data3, data4 = np.random.rand(4, 100)
fig, ax = plt.subplots(1, 1)  # create a axes
my_plotter(ax, data1, data2, {'marker': 'x'})
plt.show()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值