Matplotlib自学打卡day3

bar, scatter, plot

import matplotlib.pyplot as plt
import numpy as np

names = ['a_label', 'b_label', 'c_label']  # use the type of list to maintain names and values
values = [1, 9, 100]

plt.figure('bar, scatter, plot', figsize=(13, 3))  # this line is used to ste the size of the figure chart.

plt.subplot(131)  # subplot( nrows, ncols, nindex, **kwargs)
plt.subplot(132)
plt.scatter(names, values)  # scatter chart
plt.subplot(133)
plt.plot(names, values)  # plot can draw the line chart
plt.suptitle('Categories variables')

plt.show()

line properties

import matplotlib.pyplot as plt
import numpy as np

# working with multiple figures and axes
def f(t):
    return np.exp(-t)*np.cos(2*np.pi*t)

plt.figure('figure1')
t1 = np.arange(0., 5., 0.1)  # dot per 100ms
t2 = np.arange(0., 5., 0.02)  # dot per 20ms
plt.subplot(211)
plt.plot(t2, f(t2), 'bo', t2, f(t2), 'k')
plt.grid(True)
plt.subplot(212)
plt.plot(t1, np.cos(2*np.pi*t1), 's--')
plt.grid(True)
plt.show()

working with text

import matplotlib.pyplot as plt
import numpy as np

sigma, mu = 15, 100
x = mu + sigma*np.random.randn(10000)
# histogram chart
n, bins, patches = plt.hist(x, 50, density=1, facecolor='g', alpha=0.75)

plt.xlabel('t')
plt.ylabel('data')
plt.title('Normal distribution plot')
plt.text(60, .025, r'$\mu = 100,\ \sigma = 15$')  # $ can set the english words to english style
plt.axis([40, 160, 0, .03])  # set the axis values
plt.grid(True)  # show the threads

plt.show()
上面的代码,都是在官网上面借鉴的,不会有错,但是解释是比这些的哦,可能有错,见谅~
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值