I am trying to customize the marks of a plot (using Tikzpicture
), so that, among other things, they are not made of a given color but take the color of the line.
I have thus created a cusomized mark, called mymarks
, using \pgfdeclareplotmark
\pgfdeclareplotmark{mymarks}{
\color{red}
\pgfpathcircle{\pgfpointorigin}{4pt}\pgfusepath{fill}
\color{white}
\pgfpathcircle{\pgfpointorigin}{2pt}\pgfusepath{fill}
}
For the moment, due to the declaration \color{red}
, my marks have the perfect shape but are always red. Yet, I would like to have them of the color of the curve they are put on. In the following screenshot, for instance, I would like them to be purple on the purple curve, yellow on the yellow curve and blue on the blue curve. I would thus like to use something like \color{\pgfcolor}
(by analogy to the \pgfpointorigin
that pass the coordinates of the points) but that does not work.
Do you have any idea how to do that?
Here is a reduced example of what I coded:
\documentclass[12pt,a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfdeclareplotmark{mymarks}{
\color{red}
\pgfpathcircle{\pgfpointorigin}{4pt}\pgfusepath{fill}
\color{white}
\pgfpathcircle{\pgfpointorigin}{2pt}\pgfusepath{fill}
}
\begin{document}
\begin{tikzpicture}[xscale=1, yscale=1]
\draw[->] (-0.5, 0) -- (11,0);
\draw[->] (0, -0.5) -- (0,11);
\draw [color=blue, line width=2pt] plot [mark = mymarks] coordinates {(0,0) (1,1) (2,2) (3,5) (4,8) (5,2) (6,9) (7,5) (8,4) (9,3) (10,1)};
\draw [color=yellow, line width=2pt] plot [mark = mymarks] coordinates {(0,8) (1,7) (2,6) (3,4) (4,8) (5,7) (6,8) (7,9) (8,3) (9,1) (10,3)};
\draw [color=green, line width=2pt] plot [mark = mymarks] coordinates {(0,4) (1,4) (2,4) (3,8) (4,3) (5,5) (6,3) (7,2) (8,7) (9,8) (10,7)};
\end{tikzpicture}
\end{document}
With this, I get the following result:
What I would like to get is this:
(I did that manually by creating mymarksblue
, mymarksyellow
and mymarksgreen
, but I would like to avoid creating one type of mark for every color I have in my actual document, as there are many of them)
Thank you so much!
Simon