PGFPlots Lines – Increasing the Length of Lines Created by PGFPlots

pgfplotstikz-pgf

I have a command to draw some lines through a text:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
 \begin{document}

\scalebox{0}{%
\begin{tikzpicture}
    \begin{axis}[hide axis]
        \addplot [
        color=orange,
        solid,
        line width=1.3pt,
        forget plot
        ]
        (0,0);\label{oranged}
        \addplot [
        color=red!30.6!green!0!blue!55.7!,
        densely dashed,
        line width=1.7pt,
        forget plot
        ]
        (0,0);\label{purpled}
        \addplot [
        color=green,
        dash pattern={on 10pt off 2pt},
        line width=1.6pt,
        forget plot
        ]
        (0,0);\label{greened}
    \end{axis}
  \end{tikzpicture}%
}%


 I have \ref{purpled} and \ref{oranged}  and \ref{greened}.


 \end{document}

This command creates lines with a special length. I did anything to increase the length of the lines, although I was not succesful. does anyone know how we reach this goal.

Best Answer

Not sure I understand exactly what you are attempting to do, but it is better to just use tikz directly to draw instead of using pgfplots.

In the code below, the \DrawLine macro will draw a line of a given length with given draw parameters. I used \DrawLine to define \Purpled, \Greened and \Oranged which yields the second line below:

enter image description here

Code:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}

\newcommand*{\DrawLine}[2][]{%
    \tikz [baseline] \draw [#1] (0,0.5ex) -- ++(#2,0);%
}
\newcommand*{\Purpled}[1]{%
    \DrawLine[
        draw=red!30.6!green!0!blue!55.7!, 
        dash pattern={on 10pt off 2pt}, 
        densely dashed,
        line width=1.6pt,
    ]{#1}%
}
\newcommand*{\Greened}[1]{%
    \DrawLine[
        draw=green,
        dash pattern={on 10pt off 2pt},
        line width=1.6pt,
    ]{#1}%
}
\newcommand*{\Oranged}[1]{%
    \DrawLine[
        draw=orange,
        solid,
        line width=1.3pt,
    ]{#1}%
}


\begin{document}
\scalebox{0}{%
\begin{tikzpicture}
    \begin{axis}[hide axis]
        \addplot [
        color=orange,
        solid,
        line width=1.3pt,
        forget plot
        ]
        (0,0);\label{oranged}
        \addplot [
        color=red!30.6!green!0!blue!55.7!,
        densely dashed,
        line width=1.7pt,
        forget plot
        ]
        (0,0);\label{purpled}
        \addplot [
        color=green,
        dash pattern={on 10pt off 2pt},
        line width=1.6pt,
        forget plot
        ]
        (0,0);\label{greened}
    \end{axis}
  \end{tikzpicture}%
}%


 I have \ref{purpled} and \ref{oranged}  and \ref{greened}.

 I have \Purpled{0.65cm} and \Oranged{1.0cm}  and \Greened{1.0cm}.

\end{document}