3

Could anybody help to build charts like in the picture?

enter image description here

This is the furthest I can go. Specially blocked in the charts with jumps and curved:

\documentclass[tikz,border=3mm,preview]{standalone}
\usetikzlibrary{arrows.meta,positioning,quotes}
\usepackage{amsmath}
\begin{document}
 \begin{tikzpicture}[>={Triangle[]}
                    ]
  % coordinate
 \draw[->] (-0.1,0) node[below left] {0}
               -- (3,0);
 \draw[->] (0,-0.1) -- (0,3.5);
 % horizontal line
 \draw (-0.1,3.5) node[above] {$_{t}p_{x}^{'^{(1)}}$} -- + (0,0);
 \draw (3.3, 0) node[left] {$t$} -- + (0,0);
  % vectors
  \path[draw=red, fill=red, ultra thick]
    (0,2) to [pos=0.5] + (2,-0.3)    
    (2,1.7) to [pos=0.9] + (3,-0.7);
 \end{tikzpicture}   
 \end{document}

Thanks for your support!!!

Updating*

Next step would be to draw the following graph:

enter image description here

and I was almost able to do for both figures it with the following code:

\documentclass[tikz,border=3mm,preview]{standalone}
\usetikzlibrary{arrows.meta,decorations.pathreplacing,positioning,quotes}
\usepackage{amsmath}

\begin{document}

\begin{tikzpicture}[
>={Triangle[]}
                ]
% axes
\draw[->] (-0.1,0) -- (3.5,0.0) node[right] {$t$};
\draw[->] (0,-0.1) -- (0,3.5) node[above] {$_{t}p_{x}^{'^{(3)}}$};
\node[below left] at (0,0) {0};
% curve
\path[draw=red, ultra thick]
(0,2) node[left] {$1$} -- ++ (1,0.0) -- + (0.0,0.0)
(1,1.69)  -- ++ (1,0) -- + (0,0)
 coordinate[midway,pin=above:$1-\frac{1}{2}q'^{(3)}_x$] (a)
(2,1.4)  -- ++ (0.5,0) -- + (0,0)
coordinate[midway,pin=right:$1-q'^{(3)}_x$] (b);
% dashed line
\draw[densely dashed]
(0,1.7) -| (1,0) node[below] {$1/2$}
(2,1.4) |- (1,0) %node[below] {$1$};
 \end{tikzpicture}

 \begin{tikzpicture}[>={Triangle[]}
                ]
% axes
 \draw[->] (-0.1,0) -- (3,0.0) node[below] {$t$};
\draw[dashed] (0.75,0) -- (0.75,1.5) node[below] {$1/2$};
\draw[dashed] (1.55,0) -| (1.55,0.93) node[below] {$1$};
\draw[->] (0,-0.1) -- (0,3.5) node[above] {$_{t}p_{x}^{'^{(\gamma)}}$};
\node[below left] at (0,0) {0};
 % curves
 \path[draw=red, ultra thick]
 (0,1.9) node[left] {$1$} 
 .. controls + (2mm,-1mm) and + (1mm,-0.5mm) .. (0.7,1.65) 
 coordinate[midway,pin=above right:$p'^{(1)}_xp'^{(2)}_x$ (1)] (a)
 (0.75,1.5) .. controls + (2mm,-2mm) and + (2mm,-1mm) .. (1.5,1.15)    
 coordinate[midway,pin=right:$p'^{(1)}_xp'^{(2)}_x\Big(1-\frac{1}
 {2}q'^{(3)}_{x}\Big)$] (a)
 (1.65,0.95) .. controls + (-2mm,1mm) and + (-3mm,0.5mm) .. (1.9,0.9)
 coordinate[midway,pin=below right:$p'^{(1)}_xp'^{(2)}_x(1-q'^{(3)}_{x})$](b);              
 % dashed line
 \draw[densely dashed]
 %(0.75,0) -- (0.75,1.5) node[below] {$1/2$}
 %(1.55,0) -| (1.55,0.93) %node[below] {$1$};
 % brace
 %\draw[decorate,decoration={brace,mirror,raise=0.5mm}]
 %(0,2) -- coordinate[left=2mm,
 %pin=below left:$q^{(\gamma)}_x$] (a) (0,1);
 \end{tikzpicture}

 \end{document}

However two problems arised:

enter image description here enter image description here

1) The x-axis, as I am not able to place the coordinates properly because in one of them I am able to place it where needed but the dashed line has to be only vertical, whereas in the other despite of having the vertical dashed line, the coordinate is not possible to place it in the x-axis properly.

2) In the original charts can be seen a dot at the beginning of each piecewise function which I am not able to reproduce it.

3) Finally in the curved chart, I am having problems to make them exactly and proportionally curved one with the following as can be seen with my code. Also the position of the equations cannot be placed but above, above-right, above-left, right, left or below, without playing with them around (in any case this is a minor issue not very important)

Hope it is clear what I am trying to get.

Thanks for your support!!!

1 Answer 1

4

As starting point:

\documentclass[tikz,border=3mm,preview]{standalone}
\usetikzlibrary{arrows.meta,decorations.pathreplacing,positioning,quotes}
\usepackage{amsmath}

    \begin{document}
\begin{tikzpicture}[
    >={Triangle[]}
                    ]
    % axes
\draw[->] (-0.1,0) -- (3,0.0) node[right] {$t$};
\draw[->] (0,-0.1) -- (0,3.5) node[above] {$_{t}p_{x}^{'^{(1)}}$};
\node[below left] at (0,0) {0};
    % curve
\path[draw=red, ultra thick]
    (0,2.0) node[left] {$1$} -- ++ (2,-0.3) -- + (1,-0.7);
    % dashed line
\draw[densely dashed]
    (0,1.7) -| (2,0) node[below] {$1$};
    % brace
\draw[decorate,decoration={brace,mirror,raise=0.5mm}]
    (0,2) -- coordinate[left=2mm,
                        pin=below left:$q'^{(1)}_x$] (a) (0,1.7);
\end{tikzpicture}
    \end{document}

enter image description here

On similar way can be drawn other images. Edit: For example, for the last one you can extend showed code with:

    % curves
\path[draw=red, ultra thick]
    (0,2.0) node[left] {$1$} 
            .. controls + (5mm,-3mm) and + (-5mm,0mm) .. (2,1.7) 
            coordinate[midway,pin=above right:$p'^{(1)}_xp'^{(2)}_x$] (a)
    (2,1.3) .. controls + (3mm,-1mm) and + (-3mm,0mm) .. (3,1.1)
            coordinate[midway,pin=above right:$p'^{(1)}_xp'^{(2)}_x(1-q)$] (b);

and accordingly changes coordinates for brace and dashed line. This shouldn't be "big deal", isn't it? Any way complete MWE is:

\documentclass[tikz,border=3mm,preview]{standalone}
\usetikzlibrary{arrows.meta,decorations.pathreplacing,positioning,quotes}
\usepackage{amsmath}

    \begin{document}
\begin{tikzpicture}[
    >={Triangle[]}
                    ]
    % axes
\draw[->] (-0.1,0) -- (3,0.0) node[right] {$t$};
\draw[->] (0,-0.1) -- (0,3.5) node[above] {$_{t}p_{x}^{'^{(1)}}$};
\node[below left] at (0,0) {0};
    % curves
\path[draw=red, ultra thick]
    (0,2.0) node[left] {$1$} 
            .. controls + (5mm,-3mm) and + (-5mm,0mm) .. (2,1.7) 
            coordinate[midway,pin=above right:$p'^{(1)}_xp'^{(2)}_x$] (a)
    (2,1.3) .. controls + (3mm,-1mm) and + (-3mm,0mm) .. (3,1.1)
            coordinate[midway,pin=above right:$p'^{(1)}_xp'^{(2)}_x(1-q)$] (b);
    % dashed line
\draw[densely dashed]
    (0,1.3) -| (2,0) node[below] {$1$};
    % brace
\draw[decorate,decoration={brace,mirror,raise=0.5mm}]
    (0,2) -- coordinate[left=2mm,
                        pin=below left:$q'^{(1)}_x$] (a) (0,1.3);
\end{tikzpicture}
    \end{document}

Nor in the first nor in the second MWE I didn't bother with your math expressions, this you can do yourself (the way as you use in your MWE is not the best one).

enter image description here

6
  • And how can I curve the lines and add the equation above them, like in the last chart? I was able to make the first three even with the jumps but unable to curve them.
    – José
    Commented Aug 26, 2016 at 8:05
  • done. for curve you should use .. controls .. macro. It will be very helpfull, if you start to read TikZ manual, at least tutorials (for example 2 Tutorial: A Picture for Karl’s Students). Short and educative.
    – Zarko
    Commented Aug 26, 2016 at 14:06
  • That's ok, no problem with the math expressions. However, I am having troubles with the non-continuous function. First with the position of the curves and second with the x-axis. I have to edit your answer to show you my code and original picture. Shall I? Thanks
    – José
    Commented Aug 30, 2016 at 8:28
  • It would be better, that you edit your question and add/show what you like to achieve (with use of any part of my code). Otherwise the track of question/answer will be lost. If now you have some new specific new problem, maybe new question be appropriate.
    – Zarko
    Commented Aug 30, 2016 at 10:01
  • uf, this is more like new question ... since on this question you already have accepted answer, less people will see your update, less attention you will receive. And frankly said, some of your new question I don't understand well, what is the problem. This new pictures are only extension of the second picture/MWE in my answer.
    – Zarko
    Commented Aug 30, 2016 at 15:20

You must log in to answer this question.

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