Как изменить цвет или форму отдельных маркеров

Как изменить цвет или форму отдельных маркеров

это снова я :)

Я пытаюсь построить график с помощью pgfplots. Однако мне нужно, чтобы отдельные маркеры отличались от остальных, например, в примере ниже я хочу, чтобы маркер из 'a' для 1970 года и маркер из 'b' для 1990 года были x, а все остальные были шарами (*). (Я был бы так же рад, если бы вы подсказали мне способ различать их по цвету - надеюсь, вы понимаете, что я имею в виду.) Как мне изменить эти отдельные маркеры? Если уже есть тема по этому вопросу, которую я не нашел, пожалуйста, дайте мне знать.

Мой пример:

\begin{figure}
\centering
\begin{tikzpicture}
  \begin{axis}[width=\textwidth, xlabel = year,%\,/\,Tsd. Tonnen,
      xmin = 1965, xmax = 2015,
      xtick={1960, 1970, 1980, 1990, 2000, 2010},
      x tick label style={/pgf/number format/1000 sep=},
      ylabel = example,
      ymin = 1000, ymax = 5000,
      y tick label style={/pgf/number format/1000 sep=},]
      \addplot 
      coordinates {
(1960,  1650)
(1970,  2550)
(1980,  4050)
(1990,  4550)
(2000,  3550)
(2010,  3750)
         };
       \addplot 
      coordinates {
(1960,  1600)
(1970,  2500)
(1980,  4000)
(1990,  4500)
(2000,  3500)
(2010,  3700)
         };
\legend{a, b}
   \end{axis}
\end{tikzpicture}
\vspace*{0.4cm} 
\caption[Example.]{Example.}
\end{figure}

И картина выглядит так:

введите описание изображения здесь

Заранее спасибо! :)

решение1

Потому что я думал, что вы хотите объединить две функции из вашегодругой вопроси это я использовал как начало.

Чтобы достичь желаемого, вы можете воспользоваться функцией scatter/classes. О том, как это работает, читайте в комментариях в коде.

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{
        % I assume you *never* want to use the `1000 sep',
        % so remove it *everywhere* with this one call
        /pgf/number format/1000 sep=,
    }
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            xmin=1965,
            xmax=2015,
            xlabel=year,
            xtick={1960,1970,...,2010},
            ymin=1000,
            ymax=5000,
            ylabel=example,
            % -----------------------------------------------------------------
            % make use of the "scatter" feature and say that the "classes" are
            % given explicitly in symbolic notation
            scatter,
            point meta=explicit symbolic,
            % define as many classes as you need and provide the style to each class
            % (so the "non-default" classes can be either noticed, I changed
            %  also changed the marker size)
            scatter/classes={
                a={},       % empty argument means: use the default style
                b={mark=triangle*,orange,mark size=5pt},
                c={mark=x,green,mark size=5pt}
            },
        ]
            % I changed your coordinates to a table, because than the scatter
            % classes are to add much easier
            %
            % Also I just used an empty line to "break" the connecting line
            % (instead of adding a dummy coordinate with a `NaN' value)
            \addplot table [x=year,y=value,meta=label] {
                year    value   label
                1960    1650    a
                1970    2550    b
                1980    4050    a
                1990    4550    a

                2000    3550    a
                2010    3750    a
             };
            \addplot table [x=year,y=value,meta=label] {
                year    value   label
                1960    1600    a
                1970    2500    a
                1980    4000    a
                1990    4500    c

                2000    3500    a
                2010    3700    a
             };

            % we have to adjust the legend, because in `scatter/classes' this
            % works a bit different
            \legend{
                A,  % class "a" of first `\addplot'
                ,   % class "b" of first `\addplot'     <-- you don't want to show
                ,   % class "c" of first `\addplot'     <-- you don't want to show
                B,  % class "a" of second `\addplot'
%                ,   % ...
%                ,   % ...
            }
        \end{axis}
    \end{tikzpicture}
\end{document}

изображение, показывающее результат кода выше

Связанный контент