当前位置: 首页 > news >正文

matplotlib latex表格

使用python3环境

import matplotlib.gridspec as gridspec
import matplotlib.pyplot as pltimport numpy as np
import matplotlib as mpl
#mpl.use('pgf')def figsize(scale, nplots = 1):fig_width_pt = 390.0                          # Get this from LaTeX using \the\textwidthinches_per_pt = 1.0/72.27                       # Convert pt to inchgolden_mean = (np.sqrt(5.0)-1.0)/2.0            # Aesthetic ratio (you could change this)fig_width = fig_width_pt*inches_per_pt*scale    # width in inchesfig_height = nplots*fig_width*golden_mean              # height in inchesfig_size = [fig_width,fig_height]return fig_sizepgf_with_latex = {                      # setup matplotlib to use latex for output"pgf.texsystem": "xelatex",        # change this if using xetex or lautex"text.usetex": True,                # use LaTeX to write all text"font.family": "serif","font.serif": [],                   # blank entries should cause plots to inherit fonts from the document"font.sans-serif": [],"font.monospace": [],"axes.labelsize": 10,               # LaTeX default is 10pt font."font.size": 10,"legend.fontsize": 8,               # Make the legend/label fonts a little smaller"xtick.labelsize": 8,"ytick.labelsize": 8,"figure.figsize": figsize(1.0),     # default fig size of 0.9 textwidth"pgf.preamble": "\n".join([r"\usepackage[utf8x]{inputenc}",    # use utf8 fonts becasue your computer can handle it :)r"\usepackage[T1]{fontenc}",        # plots will be generated using this preamble]),}
mpl.rcParams.update(pgf_with_latex)
# gs2 = gridspec.GridSpec(1, 2)
# gs2.update(top=1-2/3-0.05, bottom=0, left=0.15, right=0.85, wspace=0.0)ax = plt.subplot()
ax.axis('off')
s1 = r'$\begin{tabular}{ |c|c| }  \hline Correct PDE & $u_t + u u_x + 0.0025 u_{xxx} = 0$ \\  \hline Identified PDE (clean data) & '
s2 = r'$u_t + %.3f u u_x + %.7f u_{xxx} = 0$ \\  \hline ' % (0.5,0.5)
s3 = r'Identified PDE (1\% noise) & '
s4 = r'$u_t + %.3f u u_x + %.7f u_{xxx} = 0$  \\  \hline ' % (0.15, 0.2)
s5 = r'\end{tabular}$'
s = s1+s2+s3+s4+s5
ax.text(-0.1,0.2,s)

结果如下
在这里插入图片描述

相关文章:

  • 每日一题---有效的括号问题
  • 双指针用法练习题(2024/5/26)
  • 通过unsplash引入图片素材
  • 小程序的深层了解
  • React 如何自定义 Hooks
  • Win11禁用数字强制签名:解放硬件选择,自由安装应用
  • CasaOS系统玩客云安装内网穿透工具实现无公网IP远程访问
  • 内存函数详解,包含部分字符串函数
  • 深入理解python列表与字典:数据结构的选择与性能差异
  • 07、SpringBoot 源码分析 - SpringApplication启动流程七
  • 入门五(项目介绍及登录和发布需求)
  • k8s 创建 LoadBalancer 类型的 svc
  • python数据分析-CO2排放分析
  • 安卓开发--安卓使用Echatrs绘制折线图
  • 二.对配置文件中数据库密码进行加密
  • CSS3 变换
  • Docker 笔记(2):Dockerfile
  • Electron入门介绍
  • es6--symbol
  • happypack两次报错的问题
  • HTTP--网络协议分层,http历史(二)
  • idea + plantuml 画流程图
  • iOS高仿微信项目、阴影圆角渐变色效果、卡片动画、波浪动画、路由框架等源码...
  • laravel 用artisan创建自己的模板
  • Python打包系统简单入门
  • 浅谈Golang中select的用法
  • 深入浅出Node.js
  • 世界编程语言排行榜2008年06月(ActionScript 挺进20强)
  • 云大使推广中的常见热门问题
  • 做一名精致的JavaScripter 01:JavaScript简介
  • Spring第一个helloWorld
  • 如何通过报表单元格右键控制报表跳转到不同链接地址 ...
  • #07【面试问题整理】嵌入式软件工程师
  • #includecmath
  • #QT(QCharts绘制曲线)
  • #QT(串口助手-界面)
  • #我与Java虚拟机的故事#连载12:一本书带我深入Java领域
  • $.ajax,axios,fetch三种ajax请求的区别
  • $forceUpdate()函数
  • ( )的作用是将计算机中的信息传送给用户,计算机应用基础 吉大15春学期《计算机应用基础》在线作业二及答案...
  • (1)STL算法之遍历容器
  • (11)iptables-仅开放指定ip访问指定端口
  • (2024)docker-compose实战 (8)部署LAMP项目(最终版)
  • (9)目标检测_SSD的原理
  • (C语言)fgets与fputs函数详解
  • (html5)在移动端input输入搜索项后 输入法下面为什么不想百度那样出现前往? 而我的出现的是换行...
  • (Java入门)抽象类,接口,内部类
  • (附源码)springboot掌上博客系统 毕业设计063131
  • (附源码)ssm本科教学合格评估管理系统 毕业设计 180916
  • (利用IDEA+Maven)定制属于自己的jar包
  • (免费领源码)Java#ssm#MySQL 创意商城03663-计算机毕业设计项目选题推荐
  • (三)Honghu Cloud云架构一定时调度平台
  • (三分钟了解debug)SLAM研究方向-Debug总结
  • (原)本想说脏话,奈何已放下
  • (转)http协议