8

I want to illustrate a material model, especially the identical loading and unloading path, which are illustrated via arrows that follow the material model in the following picture.

Pseudo-result

I want to put labels on the arrows specifying loading and unloading. I managed to do that with the decorations library from this post, but I am not really happy with the result. Here are the issues:

  • The Loading should not be located exactly on the arrow but rather have a little space between text and arrow.
  • The decoration causes an arrow-tip at the beginning of the arrow I can't get rid of.
  • I'd like to center the text along the array length, not use the left indent.
  • Using the decorations-library the text looks kind of pixelated. Is there an alternative ?

Can anyone plz help me with any of the mentioned points?

\documentclass[a4paper,10pt]{scrreprt}
\usepackage[T1]{fontenc}
% \usepackage[utf8]{inputenc}
\usepackage[latin1]{inputenc}
\usepackage{geometry}
\geometry{a4paper,left=25mm,right=25mm, top=25mm, bottom=25mm}
\usepackage{pgfplots}
\usetikzlibrary{decorations.text}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    domain=0:2,
    xmin=0, xmax=2.25,
    ymin=0, ymax=4.5,
    samples=100,
    axis y line=center,
    axis x line=middle,
]
    \addplot+[mark=none] {2*0.7*(1+x)*(1-1/(1+x)^3)};
    \addplot+[->,mark=none, black,
          decoration={text along path,
              text={Loading},
              text align={left indent={0.25\dimexpr\pgfdecoratedpathlength\relax}}
          },
          postaction={decorate},
    ][domain=0.5:1.5] {2*0.7*(1+x)*(1-1/(1+x)^3)+0.5};
    \addplot+[<-,mark=none, black][domain=0.5:1.5] {2*0.7*(1+x)*(1-1/(1+x)^3)-0.5};
\end{axis}
\end{tikzpicture}
\end{document}

Edit:

Thanks to @Harish Kumar I could solve the problems. Unfortunately, the decorations-library produces somewhat fuzzy text which looks like a pixel-graphics. Is there any way to circumvent this?

enter image description here

raedma
  • 1,794
  • Instead of using text align={left indent...} use text align={align=center}. I don't know how to fix the extra arrow head though :-) – darthbith Apr 08 '15 at 09:54
  • If you wonder how to offset the text from the line, see this answer: http://tex.stackexchange.com/a/38708/32374 (not related directly to this question, but maybe a future question :-)) – darthbith Apr 08 '15 at 09:55
  • For 1 and 3 use raise=1ex,text align={center}. For 2, I am looking at it. –  Apr 08 '15 at 09:57

1 Answers1

8

For increasing the gap between the line and text, you can use raise=<dimen>. To align text at the center, use text align=center. I could not find out why the extra arrow head comes (it is due to decorations, but why...). To bypass that extra head, you can plot two times, once with decoration and another with line like

\addplot[draw=none,
          postaction={decorate,decoration={text along path,
              text={Loading},raise=1ex,
              text align={center}
          }},
          domain=0.5:1.5,
    ] {2*0.7*(1+x)*(1-1/(1+x)^3)+0.5};     %%<--- decoration alone
    \addplot+[mark=none,black,
          domain=0.5:1.5,->,samples=150
    ] {2*0.7*(1+x)*(1-1/(1+x)^3)+0.5};     %% line alone

Code:

\documentclass[a4paper,10pt]{scrreprt}
\usepackage[T1]{fontenc}
% \usepackage[utf8]{inputenc}
\usepackage[latin1]{inputenc}
\usepackage{geometry}
\geometry{a4paper,left=25mm,right=25mm, top=25mm, bottom=25mm}
\usepackage{pgfplots}
\usetikzlibrary{decorations.text}

\pgfplotsset{compat=1.12}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
    domain=0:2,
    xmin=0, xmax=2.25,
    ymin=0, ymax=4.5,
    samples=100,
    axis y line=center,
    axis x line=middle,
]
    \addplot+[mark=none,samples=150] {2*0.7*(1+x)*(1-1/(1+x)^3)};
    \addplot[draw=none,
          postaction={decorate,decoration={text along path,
              text={Loading},raise=1ex,
              text align={center}
          }},
          domain=0.5:1.5,
    ] {2*0.7*(1+x)*(1-1/(1+x)^3)+0.5};
    \addplot+[mark=none,black,
          domain=0.5:1.5,->,,samples=150
    ] {2*0.7*(1+x)*(1-1/(1+x)^3)+0.5};
    \addplot[draw=none,
          postaction={decorate,decoration={text along path,
              text={Unloading},raise=-2ex,
              text align={center},
          }},
          domain=0.5:1.5
          ] {2*0.7*(1+x)*(1-1/(1+x)^3)-0.5};
    \addplot+[<-,mark=none, black,domain=0.5:1.5,samples=150] {2*0.7*(1+x)*(1-1/(1+x)^3)-0.5};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

No fuzzy text for me

enter image description here

May be your system is using bitmap fonts.