1

I have to plot a figure in my paper, but I find problems in doing it (see below), can you give me some tips?

Some code (either LaTeX or Matlab) will be helpful.

enter image description here

5
  • I don't see any of the problems below (or above). Please post the code that's giving you trouble. Jan 27, 2015 at 12:02
  • I do not know how to plot it.@PaulGessler
    – xiaojidan
    Jan 27, 2015 at 12:05
  • At least provide some data or code.
    – percusse
    Jan 27, 2015 at 12:07
  • I just know how to plot them, not some detailed data. Can you know how to plot them? @percusse
    – xiaojidan
    Jan 27, 2015 at 12:10
  • You could try the pgfplots package. It takes some work to learn all of the details of pgfplots, but it is very powerful. Try pgfplots.sourceforge.net/pgfplots.pdf Jan 27, 2015 at 12:17

2 Answers 2

4

This should get you started. The code is raw and not coloured, these are left as assignment if you like. (I gotta run now sorry)

\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}

enter image description here

1
  • Great! Thank you very much. A beautiful figure is coming~
    – xiaojidan
    Jan 28, 2015 at 0:43
6

I don't know if it has to be this difficult but here it goes. But seriously this plot is anything but beautiful.

\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}

enter image description here

1
  • Wa! Great! Thanks a lot. So beautiful figure. I like it. BTW, can you finish it using other code such as Matlab?
    – xiaojidan
    Jan 28, 2015 at 0:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .