【漫漫科研路\pgfplots】多个子图共用一个图例
2017-12-02 18:15
344 查看
十月底,投完会议之后,便对科研写作方面遇到的问题进行了探索。问题主要有:
问题:
文献管理问题:在写论文的过程中,经常要引用他人文献,这时需要费时去寻找。另一方面,有时想要查看曾经读到的某篇文章提到的方法, 也需要去耗时去寻找。
画图问题:怎样画出好看的图?
解决方案:
针对问题1: 使用JabRef
针对问题2:使用Pgfplots
后面我将会用一系列文章来记录JabRef和Pgfplots的常用使用方法。本文介绍一下如何让多个子图共用一个图例
- Case1: 所有的子图有相同的曲线
实现代码如下:
Case2: 子图有不同的曲线
实现代码如下:
参考文献:
[1] pgfplots manual: http://pgfplots.sourceforge.net/pgfplots.pdf
[2]https://tex.stackexchange.com/questions/192729/pgfplots-trying-to-combine-legends
[3]https://tex.stackexchange.com/questions/383547/refnamed-pgfplot-externalization-and-hyperref-gives-warning-namepgfplotsli
本科舍友不幸得了黑色素癌, 在此恳求大家能给予帮助,在此谢谢大家!以下是水滴筹的链接:
https://www.shuidichou.com/cf/contribute/7d975cfc-e508-4549-acb1-5a31ceb759a1?channel=wx_charity_pyq&source=7hEPKZfbC7kzc7ndTKDD6cZriDdYH4TQ&forwardFrom=5&sharedv=2008
如果各位嫌麻烦,也可以通过左下角的微信扫码进行捐款,我将悉数给予舍友。再次感谢大家的帮助!
问题:
文献管理问题:在写论文的过程中,经常要引用他人文献,这时需要费时去寻找。另一方面,有时想要查看曾经读到的某篇文章提到的方法, 也需要去耗时去寻找。
画图问题:怎样画出好看的图?
解决方案:
针对问题1: 使用JabRef
针对问题2:使用Pgfplots
后面我将会用一系列文章来记录JabRef和Pgfplots的常用使用方法。本文介绍一下如何让多个子图共用一个图例
- Case1: 所有的子图有相同的曲线
实现代码如下:
\documentclass{article} \usepackage[dvipdfm]{graphicx} \def\pgfsysdriver{pgfsys-dvipdfmx.def} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{width=6cm,compat=1.15} \begin{document} \begin{center} \ref{named}\\%\pgfplotsplotfromname{named} instead of \ref{named} if the codes doesn't work \begin{tikzpicture} \begin{axis}[ legend columns=-1,%the legend are plotted horizontally legend entries={$x$}, legend to name=named,% stored in named title={subfig1}, ] \addplot {x}; \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[title={subfig2}] \addplot {x}; \end{axis} \end{tikzpicture} \end{center} \end{document}
Case2: 子图有不同的曲线
实现代码如下:
\documentclass{article} \usepackage[dvipdfm]{graphicx} \def\pgfsysdriver{pgfsys-dvipdfmx.def} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{width=6cm,compat=1.15} \usetikzlibrary{matrix} \usepgfplotslibrary{external} \newcommand*{\refne}[1]{\tikzexternaldisable\pgfplotsplotfromname{#1}\tikzexternalenable}%avoid conflict with the packet hyperref \begin{document} \begin{center} \begin{tikzpicture} %--define the legend by ourself \matrix[ matrix of nodes, draw, inner sep=0.2em, ampersand replacement=\&, font=\scriptsize, anchor=east ] { \refne{x}\& $x$\\ \refne{x2}\& $x^2$\\ }; \end{tikzpicture}\\ \begin{tikzpicture} \begin{axis}[ legend columns=-1,%the legend are plotted horizontally legend entries={$x$}, legend to name=named,% stored in named title={subfig1}, ] \addplot {x};\label{x} \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[title={subfig2}] \addplot[red] {x^2};\label{x2} \end{axis} \end{tikzpicture} \end{center} \end{document}
参考文献:
[1] pgfplots manual: http://pgfplots.sourceforge.net/pgfplots.pdf
[2]https://tex.stackexchange.com/questions/192729/pgfplots-trying-to-combine-legends
[3]https://tex.stackexchange.com/questions/383547/refnamed-pgfplot-externalization-and-hyperref-gives-warning-namepgfplotsli
本科舍友不幸得了黑色素癌, 在此恳求大家能给予帮助,在此谢谢大家!以下是水滴筹的链接:
https://www.shuidichou.com/cf/contribute/7d975cfc-e508-4549-acb1-5a31ceb759a1?channel=wx_charity_pyq&source=7hEPKZfbC7kzc7ndTKDD6cZriDdYH4TQ&forwardFrom=5&sharedv=2008
如果各位嫌麻烦,也可以通过左下角的微信扫码进行捐款,我将悉数给予舍友。再次感谢大家的帮助!
相关文章推荐
- 【漫漫科研路\pgfplots】子图的多种画法
- 多个子站点共用同一个Cookies验证
- 使用TMG2010让多个web服务器共用一个公网地址
- Js判断一个字符串是否包含一个子串
- 编写一个函数,它从一个字符串中提取一个子字符串
- STM32 PA0 PAB0 PC0 共用一个中断线的问题
- 两个按钮共用一个界面并且点击该界面保存按钮调用不同事件
- CSS多个选择器共用一个样式
- (转)IIS tomcat共用80端口解决一个IP多个域名:使用Nginx反向代理方式使两者兼容
- 在一个域的环境中,实现父域与子域共用一台EXCHANGE服务器 推荐
- 用java 正则表达式 计算一个字符串中某个子串的个数
- iOS在多台Mac上合作开发,共用一个账号和证书
- ecshop 站群,多模板,多域名共用一个后台
- 多个Activity之间共用一个Socket实例
- 多个域名共用一个空间最简单实用的方法
- edit中只能输入数字、小数点(只可以1个小数点)和负号+多个edit共用一个事件
- 多个tableview共用一个控制器
- 方法:VS中解决方案的多个项目共用一个文件 如CS文件或配置文件等
- 不同的单元中的类可以共用同一个命名空间
- IAR ARM、IAR STM8、IAR MSP430共用一个IDE