zoukankan      html  css  js  c++  java
  • test

    test

    获得矢量图可以用jupyter导出为markdown格式然后下载导出的压缩包,里面的svg格式文件就是矢量图,可以直接拖进Word。

    In [1]:
    import numpy as np
    from scipy import stats
    import matplotlib.pyplot as plt
    cos2s = '0*0.03*0.12*0.25*0.41*0.59*0.75*0.88*0.97*1'
    cos2 = np.array(list(map(float, cos2s.split('*'))))
    lefts = '5.2*9.1*20.5*38.8*61.5*86.4*110.1*128.9*142.3*147.1'
    left = np.array(list(map(float, lefts.split('*'))))
    rights = '5.2*9.7*22.5*41.3*64.2*87.9*111.8*131.2*143.3*147.8'
    right = np.array(list(map(float, rights.split('*'))))
    # 打开网页内绘图并调成矢量绘图模式
    %matplotlib inline
    %config InlineBackend.figure_format = 'svg'
    plt.rcParams['font.sans-serif'] = ['SimHei'] # 字体
    plt.rcParams['axes.unicode_minus'] = False
    plt.rcParams['font.size'] = 10 # 字体大小
    
    In [2]:
    plt.figure(figsize=(8, 4)) # 图片大小
    plt.grid(True) # 显示网格
    kl, bl, *_ = stats.linregress(cos2, left) # 线性回归方程
    plt.scatter(cos2, left, c='k', marker='o') # 画点
    plt.plot(cos2, kl * cos2 + bl, 'k-', label='Ⅱ左旋') # 划线
    kr, br, *_ = stats.linregress(cos2, right)
    plt.scatter(cos2, right, c='k', marker='D')
    plt.plot(cos2, kr * cos2 + br, 'k--', label='Ⅰ右旋')
    plt.title('通过两偏振器的光强I与两透光轴间夹角$\theta$的关系测量数据')
    plt.xlabel('$cos^2 \theta $')
    plt.ylabel(u'光强/$10^{-7}A$')
    plt.legend() # 显示图例
    plt.show()
    
    In [3]:
    p2 = np.arange(0, 360, 10) / 180 * np.pi
    sens = '40.8*34.6*29.9*28*28.4*31.3*36.3*42.7*49.9*56.9*62.9*'
    sens += '67.2*69.2*68.5*65.6*60.3*53.6*45.9*39.1*33.2*29.1*27.3*'
    sens += '28*31.4*36.9*44*51.8*59.3*65.7*70.2*72.7*72.1*69*'
    sens += '63.4*56.3*48.7'
    sen = np.array(list(map(float, sens.split('*'))))
    a2 = np.max(sen) / 0.75
    print(np.max(sen))
    sent = a2 * (0.75 * np.cos(p2 + np.pi / 3) ** 2 + 0.25 * np.sin(p2 + np.pi / 3) ** 2)
    print(np.max(sen) / np.min(sen), np.max(sent) / np.min(sent))
    plt.figure(figsize=(5, 5))
    plt.subplot(111, projection="polar") # 设置画图方式为极坐标
    plt.grid(True)
    plt.plot(np.append(p2, p2[0]), np.append(sen, sen[0]), 'k-o', label='测量值')
    plt.plot(np.append(p2, p2[0]), np.append(sent, sent[0]), 'k-D', label='理论值')
    plt.title('椭圆偏振光光强测量数据')
    plt.xticks(p2) # X坐标对应极坐标图的角坐标
    plt.legend()
    plt.show()
    
    72.7
    2.663003663003663 3.0
    
  • 相关阅读:
    LeetCode Array Easy 414. Third Maximum Number
    LeetCode Linked List Medium 2. Add Two Numbers
    LeetCode Array Easy 283. Move Zeroes
    LeetCode Array Easy 268. Missing Number
    LeetCode Array Easy 219. Contains Duplicate II
    LeetCode Array Easy 217. Contains Duplicate
    LeetCode Array Easy 189. Rotate Array
    LeetCode Array Easy169. Majority Element
    LeetCode Array Medium 11. Container With Most Water
    LeetCode Array Easy 167. Two Sum II
  • 原文地址:https://www.cnblogs.com/YuanZiming/p/12002723.html
Copyright © 2011-2022 走看看