Wenn ich wie im Beispiel drei Kurven mit pgfplots darstelle und mit verschiedenen Farben markiere dann stimmen die Farben im Plot und in der Legende nicht überein, wenn ich die drei Plots nacheinander sichtbar mache mit visible. Gibt es dafür eine Lösung ?

Öffne in Overleaf
\documentclass[10pt]{beamer}

\usepackage{pgfplots}

\tikzset{
    invisible/.style={opacity=0},
    visible on/.style={alt={#1{}{invisible}}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
    },
  }

\begin{document}
\frame{\frametitle{Siedetemperaturen im Vergleich}
\begin{tikzpicture}

\begin{axis}[
        xlabel=Anzahl C-Atome,
        ylabel=Siedetemperatur in $^{\circ}$C,
        xmajorgrids=true,
            grid style=dashed,
            legend style={at={(0.02,0.9)},anchor=west,},
            ]

\addplot+[visible on=<1->,
color = orange!70,
fill = orange!70,
mark = *,
only marks
] coordinates {
( 1, -161.7 )
( 2, -88.6 )
( 3, -42.2 )
( 4, -0.5 )
( 5, 36.1 )
( 6, 68.7 )
( 7, 98.4 )
( 8, 125.6 )
( 9, 150.7 )
( 10, 174.0 )
};

\addplot+[visible on=<2->,
color = blue!60,
fill = blue!60,
mark = *,
only marks
] coordinates {
(1, 65)
(2, 78)
(3, 97)
(4, 117)
(5, 138)
(6, 157)
(7, 176)
(8, 195)
(9, 215)
(10, 228)
};

\addplot+[visible on=<3->,
color = olive!70,
fill = olive!70,
mark = *,
only marks
] coordinates {
(1, -19)
(2, 20)
(3, 49)
(4, 75)
(5, 102)
(6, 131)
(7, 153)
(8, 171)
(9, 191)
(10, 209)
};

\node [draw,fill=white,anchor=north east] at (rel axis cs: 0.99,0.14) {Alkane \textcolor{orange!70}{$\bullet$} $\,$ Alkanale \textcolor{olive!70}{$\bullet$}$\,$ Alkohole \textcolor{blue!60}{$\bullet$}};
  \end{axis}
\end{tikzpicture}
}
\end{document}

gefragt 05 Jun '17, 18:43

butts's gravatar image

butts
674143440
Akzeptiert-Rate: 40%

bearbeitet 07 Feb '18, 08:01

saputello's gravatar image

saputello
11.1k154365


Wenn du die Farbe der Marker setzen möchtest musst du mark options verwenden (hat nichts mit visible on zu tun).

Öffne in Overleaf
\documentclass[10pt]{beamer}

\usepackage{pgfplots}

\tikzset{
  invisible/.style={opacity=0},
  visible on/.style={alt={#1{}{invisible}}},
  alt/.code args={<#1>#2#3}{%
    \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
  },
}

\begin{document}
\frame{\frametitle{Siedetemperaturen im Vergleich}
  \begin{tikzpicture}

    \begin{axis}[
      xlabel=Anzahl C-Atome,
      ylabel=Siedetemperatur in $^{\circ}$C,
      xmajorgrids=true,
      grid style=dashed,
      legend style={at={(0.02,0.9)},anchor=west,},
      ]

      \addplot+[visible on=<1->,
      mark options={color = orange!70, fill = orange!70},
      mark = *,
      only marks
      ] coordinates {
        ( 1, -161.7 )
        ( 2, -88.6 )
        ( 3, -42.2 )
        ( 4, -0.5 )
        ( 5, 36.1 )
        ( 6, 68.7 )
        ( 7, 98.4 )
        ( 8, 125.6 )
        ( 9, 150.7 )
        ( 10, 174.0 )
      };

      \addplot+[visible on=<2->,
      mark options={color = blue!60, fill = blue!60},
      mark = *,
      only marks
      ] coordinates {
        (1, 65)
        (2, 78)
        (3, 97)
        (4, 117)
        (5, 138)
        (6, 157)
        (7, 176)
        (8, 195)
        (9, 215)
        (10, 228)
      };

      \addplot+[visible on=<3->,
      mark options={color = olive!70, fill = olive!70},
      mark = *,
      only marks
      ] coordinates {
        (1, -19)
        (2, 20)
        (3, 49)
        (4, 75)
        (5, 102)
        (6, 131)
        (7, 153)
        (8, 171)
        (9, 191)
        (10, 209)
      };

      \node [draw,fill=white,anchor=north east] at (rel axis cs: 0.99,0.14) {Alkane \textcolor{orange!70}{$\bullet$} $\,$ Alkanale \textcolor{olive!70}{$\bullet$}$\,$ Alkohole \textcolor{blue!60}{$\bullet$}};
    \end{axis}
  \end{tikzpicture}
}
\end{document}

alt text

Wenn auch die Legende aufgedeckt werden darf statt immer vollständig zu sein, könnte man auch Beamer-Overlays und die pgfplots-Legende verwenden.

Öffne in Overleaf
\documentclass[10pt]{beamer}

\usepackage{pgfplots}

\begin{document}

\begin{frame}{Siedetemperaturen im Vergleich}
  \begin{tikzpicture}

    \begin{axis}[
      xlabel=Anzahl C-Atome,
      ylabel=Siedetemperatur in $^{\circ}$C,
      xmajorgrids=true,
      grid style=dashed,
      legend columns=3,
      legend pos=south east,
      only marks,
      ]

      \only<1->{
        \addplot+[mark=*,mark options={color = orange!70, fill = orange!70}]
        coordinates {
          ( 1, -161.7 )
          ( 2, -88.6 )
          ( 3, -42.2 )
          ( 4, -0.5 )
          ( 5, 36.1 )
          ( 6, 68.7 )
          ( 7, 98.4 )
          ( 8, 125.6 )
          ( 9, 150.7 )
          ( 10, 174.0 )
        };
        \addlegendentry{Alkane}
      }

      \only<2->{
        \addplot+[mark=*,mark options={color = blue!60, fill = blue!60}]
        coordinates {
          (1, 65)
          (2, 78)
          (3, 97)
          (4, 117)
          (5, 138)
          (6, 157)
          (7, 176)
          (8, 195)
          (9, 215)
          (10, 228)
        };
        \addlegendentry{Alkanale}
      }

      \only<3->{
        \addplot+[mark=*,mark options={color = olive!70, fill = olive!70}]
        coordinates {
          (1, -19)
          (2, 20)
          (3, 49)
          (4, 75)
          (5, 102)
          (6, 131)
          (7, 153)
          (8, 171)
          (9, 191)
          (10, 209)
        };
        \addlegendentry{Alkohole}
      }

    \end{axis}
  \end{tikzpicture}
\end{frame}

\end{document}

alt text

Permanenter link

beantwortet 05 Jun '17, 23:28

Henri's gravatar image

Henri
15.7k133943
Akzeptiert-Rate: 46%

bearbeitet 05 Jun '17, 23:39

DANKE ! gute Antwort auch dass die Legende mit den Kurven aufgedeckt wird.

(06 Jun '17, 21:33) butts
Deine Antwort
Vorschau umschalten

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Markdown-Grundlagen

  • *kursiv* oder _kursiv_
  • **Fett** oder __Fett__
  • Link:[Text](http://url.com/ "Titel")
  • Bild?![alt Text](/path/img.jpg "Titel")
  • nummerierte Liste: 1. Foo 2. Bar
  • zum Hinzufügen ein Zeilenumbruchs fügen Sie einfach zwei Leerzeichen an die Stelle an der die neue Linie sein soll.
  • grundlegende HTML-Tags werden ebenfalls unterstützt

Frage-Themen:

×296
×138

gestellte Frage: 05 Jun '17, 18:43

Frage wurde gesehen: 7,240 Mal

zuletzt geändert: 06 Jun '17, 21:33