I am a LyX user and I would like to use a line plot in one of my papers. This is simply a line with few identified points. For me the points of interest are 24, 32 and 38. Could you please tell what is the easiest way to accomplish this? I have heard about the packaged pgfplots but I do not know how to use it. It also seems an overkill for my case.

All suggestions are welcome, thank you in advance.

  • Yes, pgfplots is probably the best way to do that. But not sure what 24, 32 and 38 represent. Are those points on a number line? Nov 17, 2014 at 20:38
  • @PeterGrill Imagine points on a line. There is no need for a vertical axis. The point is to show how far they all lie from each other in just 1 dimension.
    – JohnK
    Nov 17, 2014 at 20:39

1 Answer 1


You can use tikz for simple drawings such as this:

enter image description here

If you are doing these types of figure often, then it makes sense to wrap them in a macro where you can define

  • #1 = the start value,
  • #2 = end value, and the
  • #3 = list of points to mark.




enter image description here

Code: Basic Version


\tikzset{tick style/.style={thick, black}}
\draw [thin, gray, -latex] (18,0) -- (42,0);
\foreach \Tick in {20,25,...,40} {
    \draw [tick style] (\Tick,1.5ex) -- (\Tick,-1.5ex) node [below] {$\Tick$} ;
\foreach \X in {24, 32, 38} {
    \draw [fill=red] (\X,0) circle (4pt) node [above, blue] {$\X$};

Code: Macro Version


\tikzset{number line style/.style={thin, gray, -latex}}
\tikzset{tick style/.style={thick, black}}

%% http://tex.stackexchange.com/questions/175507/scale-tikzpicture-to-enclosing-minipage
    % #1 = width
    % #2 = tikzpicture

    % #1 = x min
    % #2 = x max
    % #3 = comma separated list of points to show
        \begin{tikzpicture}[x=\MyScale cm, y=1cm]
            \draw [number line style] (#1,0) -- (#2,0);
            \pgfmathtruncatemacro{\TickEnd}{\TickStep*int(#2/\TickStep -1)}%
            \foreach \Tick in {1,...,\NumOfTicks} {
                \draw [tick style] (\CurrentTick,0.5ex) -- (\CurrentTick,-0.5ex) 
                    node [below] {\tiny$\CurrentTick$} ;
            \foreach \X in {#3} {
                \draw [fill=red] (\X,0) circle (2pt) 
                    node [above, blue] {\tiny$\X$};

  • Works wonderfully, thank you very much. There is plenty for me to learn, this is an amazing package.
    – JohnK
    Nov 17, 2014 at 20:51

You must log in to answer this question.

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