Python折线图 画图 模板

import matplotlib.pyplot as plt
import numpy as np

if __name__ == '__main__':
    
    pm_15db_3p = [302, 345, 365, 405, 425]
    pm_20db_3p = [312, 356, 375, 417, 439]
    pm_15db_rd = [200, 239, 256, 300, 320]
    pm_20db_rd = [205, 245, 264, 310, 325]
    x = [0.001, 0.005, 0.01, 0.05, 0.099]
    
    color1 = '#EC4B51' ## red
    color2 = '#26F03C' ## green 

    plt.plot(x, pm_15db_3p, '-', label='Pc_max=15dBm,3-partite', color = color1)
    plt.plot(x, pm_20db_3p, '-',  label='Pc_max=20dBm,3-partite', color = color2)
    plt.plot(x, pm_15db_rd, '--', label='Pc_max=15dBm,Randomized', color = color1)
    plt.plot(x, pm_20db_rd, '--', label='Pc_max=20dBm,Randomized', color = color2)

    #刻度
    x_ticks = np.arange(0, 0.11, 0.01)
    y_ticks = np.arange(150,450, 50)
    plt.xticks(x_ticks) 
    plt.yticks(y_ticks)

    #点的形状
    plt.scatter(x, pm_15db_3p, marker = 'o', c = '', edgecolors = color1)
    plt.scatter(x, pm_15db_rd, marker = 'o', c = '', edgecolors = color1)

    plt.scatter(x, pm_20db_3p, marker = 'D', c = '', edgecolors = color2)
    plt.scatter(x, pm_20db_rd, marker = 'D', c = '', edgecolors = color2)
    
    #坐标轴显示范围
    plt.axis([0, 0.1, 150, 450])

    #x轴和y轴意义
    plt.xlabel('$p$0')
    plt.ylabel('$\sum_{m=1}$$C_m$(bps/Hz)')
    
    #绘制
    plt.legend()
    plt.grid()
    plt.show()

参考连接:
https://blog.csdn.net/xy707707/article/details/102677075数学公式
https://pywin.blog.csdn.net/article/details/79035928标记点
https://blog.csdn.net/helunqu2017/article/details/78736415刻度和坐标值
https://www.cnblogs.com/zf-blog/p/12191783.html 点的形状

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值