python画图笔记

python画曲线图

科研作图代码记录

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
from parameters import *
font_size = 16  
bwith = 2  # 边框宽度设置为2
plt.rcParams['xtick.direction'] = 'in' #坐标刻度方向
plt.rcParams['ytick.direction'] = 'in'
plt.rcParams['ytick.labelsize'] = font_size #刻度字体
plt.rcParams['xtick.labelsize'] = font_size

ax = plt.gca()  # 获取边框
# ax.spines['top'].set_color('red')  # 设置上‘脊梁’为红色
ax.spines['right'].set_color('none')  # 设置上‘脊梁’为无色
ax.spines['bottom'].set_linewidth(bwith)
ax.spines['left'].set_linewidth(bwith)
ax.spines['top'].set_linewidth(bwith)
ax.spines['right'].set_linewidth(bwith)
def plot_n_R(R_all, exp_data = False):
   labels = [
        'Bending radius=2cm',
        'Bending radius=3cm',
       'Bending radius=5cm',
        'Bending radius=10cm']
    linestyle_ = ['-', '--', '-.', ':']
    color_ = ['b', 'k', 'm', 'r']
    fig, ax = plt.subplots()
    markers = ['s', 'v', '^', '>', 'p', '<',  '*',  '.', 'x']
    for i, R in enumerate(R_all):
        label = labels[i]
        x = np.linspace(0, 2*L, 2*L)

        ax.plot(np.linspace(1, 2*L, 2*L-1),
                (R[1:] / R[1] - 1) * 100,
                linewidth=3,
                label=label,
                linestyle=linestyle_[i],
                color=color_[i])
    #                 marker=markers[i],
    #                 markevery=20 + 2 * i,
    #                 ms = 10,
    ax.set_xlabel('Number of bending cycles', fontsize=14)
    ax.set_ylabel('$ΔR/R_0$(%)', fontsize=14)

    #ax.set_ylim(-5, 180)
    ax.legend(prop={'size': 14},
                frameon=False,
                loc='upper left',
                bbox_to_anchor=(-0.015, 1))  # 'family' : 'Times New Roman'
    #ax.text(0, 1, '$h_2/h_1=2500$', fontdict={'family': 'Times New Roman', 'size': 16})
    fig.set_size_inches(8, 6)
    plt.savefig('2021-1-23-测试m')
    plt.show()

def plot_3d_w(w):


    X = np.arange(0, 2*L, 0.01*L)
    Y = np.arange(0, b, 0.01*b)
    X, Y = np.meshgrid(X, Y)
    Z = 5914158.57835006*sin(pi*X/20)*sin(pi*Y/10)
    fig = plt.figure()
    ax = Axes3D(fig)
    ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.viridis)
    plt.show()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值