matplotlib画图--评估表

# python3.8
# -*- coding: utf-8 -*-
# ---
# @Software: PyCharm
# @File: main8.py.py
# @Author: ---
# @Institution: BeiJing, China
# @E-mail: 
# @Site: 
# @Time: 6月 21, 2021
# ---
import matplotlib.pyplot as plt

#colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']
colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#17becf', '#9467bd', '#8c564b', '#e377c2', '#d62728']
markers = [',', 'o', '^', 'D', '+', 'X', '1', '*']
models = ['ICP', 'FGR', 'PCRNet', 'DCP-v2', 'IDAM-GNN', 'DeepGMR', 'RPMNet', 'ROPNet(ours)']
times = [0.0493, 0.1286, 0.0145, 0.0196, 0.0263, 0.0063, 0.0812, 0.0387]
Errors = [24.3766, 28.6681, 21.4136, 10.8202, 16.6100, 17.8840, 1.2343, 1.1520]

def plot_wh_methods():
    #https://blog.csdn.net/Du_Shuang/article/details/84139716
    fig = plt.figure(figsize=(6, 3), tight_layout=True)

    for m_name, m_time, m_error, m_marker, m_color in zip(models, times, Errors, markers, colors):
        plt.scatter(x=m_time,  y=m_error, s=64, c=m_color, marker=m_marker)

    plt.xlim(left=0, right=0.13)
    plt.ylim(bottom=0, top=30)

    plt.xlabel('Time(s)')
    plt.ylabel('Error(R)')

    #plt.grid()
    plt.grid(linestyle='-.')
    plt.legend(labels=models, loc="lower right")
    fig.savefig('comparison.png', dpi=1000)

def plot_wh_methods2():
    fig, ax = plt.subplots()
    for m_name, m_time, m_error, m_marker, m_color in zip(models, times, Errors, markers, colors):
        if m_name == "ROPNet":
            ax.scatter(x=m_time, y=m_error, s=88, c=m_color, marker=m_marker)
        else:
            ax.scatter(x=m_time, y=m_error, s=64, c=m_color, marker=m_marker)
            #ax.scatter(x=m_time, y=m_error, c=m_color, marker=m_marker)

    ax.set_xlim(left=0, right=0.15)
    ax.set_ylim(bottom=0, top=30)

    # 设置纵横比
    # https://stackoverflow.com/questions/7965743/how-can-i-set-the-aspect-ratio-in-matplotlib
    x0, x1 = ax.get_xlim()
    y0, y1 = ax.get_ylim()
    ax.set_aspect(abs(x1 - x0) / abs(y1 - y0))

    # ax.grid(b=True, which='major', color='k', linestyle='--')
    ax.grid(linestyle='-.')

    # scatter图在网格线上方
    # https://stackoverflow.com/questions/19677963/matplotlib-keep-grid-lines-behind-the-graph-but-the-y-and-x-axis-above
    ax.set_axisbelow(True)

    # legend位置显示
    # matplotlib的legend的title字体大小?
    # https://www.zhihu.com/question/45028370
    # matplotlib 到底该如何控制legend的位置之一?
    # https://zhuanlan.zhihu.com/p/99531531

    # https://blog.csdn.net/lanluyug/article/details/80002273
    #plt.legend(labels=models, loc="lower right", fontsize='x-large')
    plt.legend(labels=models, loc=(0.075/0.15, 3/30), fontsize=12)
    #legend = plt.legend(labels=models, loc="center right", fontsize=12)
    #legend.get_frame().set_facecolor('#EAEAEA')

    plt.xlabel('Time(s)', fontsize=12)
    plt.ylabel('Error(R)', fontsize=12)
    fig.savefig('comparison2.pdf', dpi=1000)
    fig.savefig('comparison2.png', dpi=1000)
    plt.close(fig)
    plt.show()

#plot_wh_methods()
plot_wh_methods2()

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值