With the help of \pgfplotsset{colormap=...}
you can define your own color map colors. \pgfplotsset{colormap={CM}{rgb255(1)=(4,50,4) color(5)=(yellow)}}
will for example give a dark green to yellow gradient:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\usepgfplotslibrary{colormaps}
\pgfplotsset{colormap={CM}{rgb255(1)=(4,50,4) color(5)=(yellow)}}
\begin{document}
\def\modulus{sqrt(x^2+y^2)}
\begin{tikzpicture}
\begin{axis}[
xmin = -4, xmax = 4,
ymin = -4, ymax = 4,
zmin = 0, zmax = 1,
axis equal image,
xtick distance = 1,
ytick distance = 1,
view = {0}{90},
scale = 1.5,
colorbar
]
\addplot3[
point meta = {\modulus},
quiver = {
u = {-y/\modulus},
v = {x/\modulus},
scale arrows = 0.25,
},
quiver/colored = {mapped color},
samples = 20,
- stealth,
domain = -4:4,
domain y = -4:4,
] {0};
\end{axis}
\end{tikzpicture}
\end{document}
Please note that using the above code, the new color map will be used as the default. If you want to only change the color map of a single plot, you can either use the above shown definition inside of the corrensonding tikzpicture
or use the colormap name
option as shown in the following exmple:
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\usepgfplotslibrary{colormaps}
\pgfplotsset{colormap={mymapgreen}{rgb255(1)=(4,50,4) color(5)=(yellow)}}
\pgfplotsset{colormap={mymapviolet}{rgb255(1)=(150,120,175) rgb255(5)=(81,6,60)}}
\begin{document}
\def\modulus{sqrt(x^2+y^2)}
\begin{tikzpicture}
\begin{axis}[
xmin = -4, xmax = 4,
ymin = -4, ymax = 4,
zmin = 0, zmax = 1,
axis equal image,
xtick distance = 1,
ytick distance = 1,
view = {0}{90},
scale = 1.5,
colorbar,
colormap name ={mymapgreen} %<-------
]
\addplot3[
point meta = {\modulus},
quiver = {
u = {-y/\modulus},
v = {x/\modulus},
scale arrows = 0.25,
},
quiver/colored = {mapped color},
samples = 20,
- stealth,
domain = -4:4,
domain y = -4:4,
] {0};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
xmin = -4, xmax = 4,
ymin = -4, ymax = 4,
zmin = 0, zmax = 1,
axis equal image,
xtick distance = 1,
ytick distance = 1,
view = {0}{90},
scale = 1.5,
colorbar,
colormap name ={mymapviolet} %<-------
]
\addplot3[
point meta = {\modulus},
quiver = {
u = {-y/\modulus},
v = {x/\modulus},
scale arrows = 0.25,
},
quiver/colored = {mapped color},
samples = 20,
- stealth,
domain = -4:4,
domain y = -4:4,
] {0};
\end{axis}
\end{tikzpicture}
\end{document}
Using colormap name=
you can of course also chose from the following predefined color maps: viridis
, hot
, hot2
, jet
, blackwhite
, bluered
, cool
, greenyellow
, redyellow
, and violet
.
For more information, you mght be interested in section "4.7 Markers, Linestyles, (Background) Colors and Colormaps" (especially in subsection "4.7.6 Color Maps", currently starting on page 192) of the pgfplots
manual.
\pgfplotsset{colormap=...}
as describen on page 193 of thepgfplots
manual. – leandriis Oct 18 at 21:29quiver/colored = {mapped color}
and specify the colormap. – Paúl Aguilar Oct 18 at 21:33