![如何绘制这个美丽的人物](https://linux22.com/image/304537/%E5%A6%82%E4%BD%95%E7%BB%98%E5%88%B6%E8%BF%99%E4%B8%AA%E7%BE%8E%E4%B8%BD%E7%9A%84%E4%BA%BA%E7%89%A9.png)
我必须在我的论文中绘制一个图表,但是我发现这样做存在问题(见下文),你能给我一些建议吗?
一些代码(LaTeX 或 Matlab)将会有所帮助。
答案1
这应该可以让你入门了。代码是原始的,没有颜色,如果你愿意的话,可以把它们留作作业。(我现在得走了,抱歉)
\documentclass[border=5]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.11}
\pgfdeclareplotmark{mymark}{%
\node[draw,circle,inner sep=0.5ex] (a) {};
\node[inner sep=0.5ex,above=2ex] (b) {};
\draw (b.north west) -- (b.south east);
\draw (b.north east) -- (b.south west);
\draw[thick](a.center) -- (b.center);
}
\pgfplotsset{
every axis plot post/.append style={
mark=mymark,
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ymin=0,ymax=3]
\addplot[only marks] coordinates
{(1,2) (2,1) (3,1.5) (4,1) (5,2)};
\end{axis}
\end{tikzpicture}
\end{document}
答案2
我不知道这是否必须这么难,但还是写了。不过说实话,这个情节一点也不精彩。
\documentclass[a4paper, 10pt]{article}
\usepackage{pgfplots}
\pgfplotsset{my error bars/.style={
/pgfplots/error bars/draw error bar/.code 2 args={%
\pgfkeysgetvalue{/pgfplots/error bars/error mark}{\pgfplotserrorbarsmark}%
\pgfkeysgetvalue{/pgfplots/error bars/error mark options}{\pgfplotserrorbarsmarkopts}%
\pgfplotscolormapdefinemappedcolor\pgfplotspointmetatransformed%
\definecolor{mapped mark color}{rgb}{\pgfmathresult}%
\draw[mapped mark color!80!black] ##1 -- ##2 node[pos=1,sloped,allow upside down] {%
\expandafter\tikz\expandafter[\pgfplotserrorbarsmarkopts,
draw=mapped mark color!80!black]{%
\expandafter\pgfuseplotmark\expandafter{\pgfplotserrorbarsmark}\pgfusepath{stroke}}};}}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ymin=0,ymax=0.25,width=8cm,height=6cm,ymajorgrids]
\addplot+[scatter,only marks,
mark options={scale=2,thick},mark=o,,my error bars,
error bars/.cd,y dir=plus,
y explicit,error mark=x,
error mark options={scale=2,thick},
error bar style={ultra thick},] table[y error plus=y2,y=y1,x=x] {
x y1 y2 % y2 is the error bar amount
1 0.18 0.04
2 0.14 0.02
3 0.13 0.02
4 0.12 0.025
5 0.13 0.04
6 0.15 0.08
};
\end{axis}
\end{tikzpicture}
\end{document}