1. plt.rc('font', family='Microsoft Yahei', size=10) # 为了可以输入中文标签

legend()

https://blog.csdn.net/qq_33221533/article/details/81431264

plot

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. plt.style.use("seaborn-whitegrid")
  4. x = np.linspace(0, 10, 30)
  5. '''
  6. color: 弧线颜色
  7. markersize: 标签大小
  8. linewidth: 弧线宽度
  9. markerfacecolor: 标签颜色
  10. markeredgecolor: 标签外框颜色
  11. markeredgewidth: 标签外框宽度
  12. '''
  13. plt.plot(x, np.sin(x), '-p', color="gray",markersize=15,linewidth=1,
  14. markerfacecolor='yellow',
  15. markeredgecolor='red',markeredgewidth=5)
  16. plt.ylim(-1.2,1.2)
  17. plt.show()

image.png

scatter

https://www.cnblogs.com/shuaishuaidefeizhu/p/11359826.html

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. rng = np.random.RandomState(0)
  4. x = rng.randn(100)
  5. y = rng.randn(100)
  6. colors = rng.rand(100)
  7. sizes = 100 * rng.rand(100)
  8. plt.scatter(x,y,c=colors,s=sizes,alpha=0.3,cmap="gist_stern")
  9. plt.colorbar() # 显示颜色条
  10. plt.show()

image.png

errorbar基本误差线

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. plt.style.use("seaborn-whitegrid")
  4. x = np.linspace(0,10,50)
  5. dy = 0.8
  6. y = np.sin(x)
  7. # xerr one-sidederrorbar
  8. plt.errorbar(x,y,yerr=dy,fmt='o',color="black",ecolor="red",elinewidth=3,capsize=5)
  9. plt.show()

image.png

imshow()

https://blog.csdn.net/a892573486/article/details/107542839

  1. plt.imshow(
  2. X,
  3. cmap=None,
  4. norm=None,
  5. aspect=None,
  6. interpolation=None,
  7. alpha=None,
  8. vmin=None,
  9. vmax=None,
  10. origin=None,
  11. extent=None,
  12. shape=None,
  13. filternorm=1,
  14. filterrad=4.0,
  15. imlim=None,
  16. resample=None,
  17. url=None,
  18. *,
  19. data=None,
  20. **kwargs,

参数:X

  • 图像数据。支持的数组形状是:

    • (M,N) :带有标量数据的图像。数据可视化使用色彩图。
    • (M,N,3) :具有RGB值的图像(float或uint8)。
    • (M,N,4) :具有RGBA值的图像(float或uint8),即包括透明度。
      前两个维度(M,N)定义了行和列图片,即图片的高和宽;
      RGB(A)值应该在浮点数[0, …, 1]的范围内,或者
      整数[0, … ,255]。超出范围的值将被剪切为这些界限。

      参数:cmap

  • 将标量数据映射到色彩图

  • 颜色默认为:rc:image.cmap。 | 颜色图谱 | 描述 | | —- | —- | | autumn | 红-橙-黄 | | bone | 黑-白,x线 | | cool | 青-洋红 | | copper | 黑-铜 | | flag | 红-白-蓝-黑 | | gray | 黑-白 | | hot | 黑-红-黄-白 | | hsv | hsv颜色空间, 红-黄-绿-青-蓝-洋红-红 | | inferno | 黑-红-黄 | | jet | 蓝-青-黄-红 | | magma | 黑-红-白 | | pink | 黑-粉-白 | | plasma | 绿-红-黄 | | prism | 红-黄-绿-蓝-紫-…-绿模式 | | spring | 洋红-黄 | | summer | 绿-黄 | | viridis | 蓝-绿-黄 | | winter | 蓝-绿 |

参数:norm :~matplotlib.colors.Normalize

  • 如果使用scalar data ,则Normalize会对其进行缩放[0,1]的数据值内。
  • 默认情况下,数据范围使用线性缩放映射到颜色条范围。 RGB(A)数据忽略该参数。

    参数:aspect

  • {‘equal’,’auto’}或float,可选

  • 控制轴的纵横比。该参数可能使图像失真,即像素不是方形的。
  • equal:确保宽高比为1,像素将为正方形。(除非像素大小明确地在数据中变为非正方形,坐标使用 extent )。
  • auto: 更改图像宽高比以匹配轴的宽高比。通常,这将导致非方形像素。

    参数:interpolation

  • str

  • 使用的插值方法
  • 支持的值有:’none’, ‘nearest’, ‘bilinear’, ‘bicubic’,’spline16′, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’,
    ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’, ‘mitchell’, ‘sinc’,’lanczos’.
  • 如果interpolation = ‘none’,则不执行插值

    参数:alpha

  • alpha值,介于0(透明)和1(不透明)之间。RGBA输入数据忽略此参数。

    参数:vmin, vmax : scalar,

  • 如果使用 norm 参数,则忽略 vmin vmax

  • vmin,vmax与norm结合使用以标准化亮度数据。

    参数:origin : {‘upper’, ‘lower’}

  • 将数组的[0,0]索引放在轴的左上角或左下角。

  • ‘upper’通常用于矩阵和图像。
  • 请注意,垂直轴向上指向“下”但向下指向“上”。

    参数:extent:(left, right, bottom, top)

  • 数据坐标中左下角和右上角的位置。 如果为“无”,则定位图像使得像素中心落在基于零的(行,列)索引上。

直方图 hist

  1. density :density=True是频率图,默认是频数图
  2. range :筛选数据范围,默认是最小到最大的取值范围
  3. histtype:hist柱子类型,'bar', 'barstacked', 'step', 'stepfilled'
  4. orientation:水平或垂直方向
  5. rwidth= :柱子与柱子之间的距离,默认是0