Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I created the following image:

Image

whit the following code:

\documentclass{standalone}

\usepackage{pgfplots}
    \pgfplotsset{%
        compat=newest,%
        /pgf/number format/use comma,%
        /pgf/number format/1000 sep={\,},%
        /pgf/number format/min exponent for 1000 sep=4}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[title={}, xlabel={}, ylabel={}, zlabel={},%
    legend cell align=left]

        \addplot[red, only marks]
            coordinates {(23.0175,1.64554e-15)};
        \addplot[brown, only marks]
            coordinates {(19.544,12.1362)};
        \addplot[orange, only marks]
            coordinates {(17.3908, 15.9429)};
        \addplot[green, only marks]
            coordinates {(16.3344, 18.2596)};
        \addplot[lime, only marks]
            coordinates {(18.0024, 17.6308)};
        \addplot[olive, only marks]
            coordinates {(19.9158, 10.8752)};
        \addplot[blue, only marks]
            coordinates {(19.798, 7.44025)};
        \addplot[cyan, only marks]
            coordinates {(19.4223, 4.57679)};
        \addplot[teal, only marks]
            coordinates {( 18.9801, 4.98689e-16)};

        \legend{$\gamma = -\frac{\pi}{2}$, $\gamma = -\frac{\pi}{3}$, $\gamma = -\frac{\pi}{4}$, $\gamma = -\frac{\pi}{6}$, $\gamma = 0$, $\gamma = +\frac{\pi}{6}$, $\gamma = +\frac{\pi}{4}$, $\gamma = +\frac{\pi}{3}$, $\gamma = +\frac{\pi}{2}$}
    \end{axis}
    \end{tikzpicture}

\end{document}

I want to link all points with a dotted line to show the trend. Is it possible also they represents different graph on only one coordinate?

Ps: In addition, it seems that the right axe is cropped...

share|improve this question
1  
Can you complete your code to a full MWE such that we don't need to guess your preamble to duplicate the issue here? –  percusse Oct 13 '12 at 14:03
    
@percusse Yes, sorry. Done. –  R. M. Oct 13 '12 at 14:21
    
Re cropping of the right axis: I guess that this results from using standalone without a border and the following conversion to PNG. Try \documentclass[border=5pt]{standalone} instead. –  Qrrbrbirlbel Oct 13 '12 at 14:43
    
Why not something like \addplot[smooth,dotted] coordinates { <all your coordinates in the right order> };? –  Qrrbrbirlbel Oct 13 '12 at 14:57
    
@Qrrbrbirlbel As you can see, I need points of different color and at each point must correspond a legend with the angle. For the cropping, is a problem I have also in my full document... –  R. M. Oct 13 '12 at 15:01
show 1 more comment

1 Answer

up vote 6 down vote accepted

pgfplots's scatter options seem promisingly (section 4.4.10 in the manual).

Solution with scatter

Notes (things I dislike)

  • It seems to me that a legend entry for every mark is only doable with classes.
  • It is very explicit.

Code

\documentclass[tikz,border=5pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
    \pgfplotsset{%
        compat=newest,%
        /pgf/number format/use comma,%
        /pgf/number format/1000 sep={\,},%
        /pgf/number format/min exponent for 1000 sep=4}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
  title={},
  xlabel={},
  ylabel={},
  zlabel={},
  legend cell align=left,
  legend image post style={only marks}
  ]
    \addplot[
      smooth,
      dotted,
      scatter,
      every mark/.append style={solid},
      scatter src=explicit symbolic,
      scatter/classes={
        a=red, b=brown, c=orange, d=green, e=lime, f=olive, g=blue, h=cyan, i=teal}
      ] coordinates {
      (23.0175, 1.64554e-15) [a]
      (19.544, 12.1362) [b]
      (17.3908, 15.9429) [c]
      (16.3344, 18.2596) [d]
      (18.0024, 17.6308) [e]
      (19.9158, 10.8752) [f]
      (19.798, 7.44025) [g]
      (19.4223, 4.57679) [h]
      (18.9801, 4.98689e-16) [i]
    };
    \legend{$\gamma = -\frac{\pi}{2}$, $\gamma = -\frac{\pi}{3}$, $\gamma = -\frac{\pi}{4}$, $\gamma = -\frac{\pi}{6}$, $\gamma = 0$, $\gamma = +\frac{\pi}{6}$, $\gamma = +\frac{\pi}{4}$, $\gamma = +\frac{\pi}{3}$, $\gamma = +\frac{\pi}{2}$}
    \end{axis}
    \end{tikzpicture}

\end{document}

Output

Output

The (easy) solution from my comment

I do not prefer this solution.

Code

\documentclass[tikz,border=5pt]{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[title={}, xlabel={}, ylabel={}, zlabel={},legend cell align=left]
    \addplot[red,    only marks] coordinates {(23.0175,1.64554e-15)};
    \addplot[brown,  only marks] coordinates {(19.544,12.1362)};
    \addplot[orange, only marks] coordinates {(17.3908, 15.9429)};
    \addplot[green,  only marks] coordinates {(16.3344, 18.2596)};
    \addplot[lime,   only marks] coordinates {(18.0024, 17.6308)};
    \addplot[olive,  only marks] coordinates {(19.9158, 10.8752)};
    \addplot[blue,   only marks] coordinates {(19.798, 7.44025)};
    \addplot[cyan,   only marks] coordinates {(19.4223, 4.57679)};
    \addplot[teal,   only marks] coordinates {(18.9801, 4.98689e-16)};
    \addplot[smooth,dotted] coordinates {
      (23.0175, 1.64554e-15) (19.544, 12.1362)  (17.3908, 15.9429)
      (16.3344, 18.2596)     (18.0024, 17.6308) (19.9158, 10.8752)
      (19.798, 7.44025)      (19.4223, 4.57679) (18.9801, 4.98689e-16)
    };
    \legend{$\gamma = -\frac{\pi}{2}$, $\gamma = -\frac{\pi}{3}$, $\gamma = -\frac{\pi}{4}$, $\gamma = -\frac{\pi}{6}$, $\gamma = 0$, $\gamma = +\frac{\pi}{6}$, $\gamma = +\frac{\pi}{4}$, $\gamma = +\frac{\pi}{3}$, $\gamma = +\frac{\pi}{2}$}
  \end{axis}
\end{tikzpicture}
\end{document}

Output

The output is the same as the one above.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.