I am having problem in increasing the distance between the labels in a contour plot in a TikZ picture. I tried a value from 10
to 10000
for the key contour/label distanc
just to have only one label on each contour level. All I tried didn't give me the result I want. Is there something that I am missing?
Here is the code I used:
\documentclass[crop=true,border=0mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis on top,
title = {$\omega_\phi\left(x, \sigma\right) = \frac{\Gamma}{\pi{R_c}^2}\exp\left[-\frac{\left(x-x_0\right)^2+\left(\sigma-R_0\right)^2}{{R_c}^2}\right]$},
xmin=2, xmax=3,
ymin=2, ymax=3,
view={0}{90},
xlabel = {$x$},
ylabel = {$\sigma$},
]
\addplot3[
contour gnuplot = {contour label style={
nodes={text=black},
/pgf/number format/fixed,
/pgf/number format/fixed zerofill=true,
/pgf/number format/precision=1,}},
samples=2000,
contour/draw color={black},
contour/label distance=1000,
]
{1/3.1415927/0.25^2*exp(-((x-2.5)^2+(y-2.5)^2)/0.25^2)};
\end{axis}
\end{tikzpicture}
\end{document}
I couldn't get contour/label distance=1000,
to work for my case. The following is the picture of the above code with samples=2000
and contour/label distance=1000,
. I would like to have only one label on each contour.
Could someone help me?
Best Answer
contour/label distance
is a length and needs some units, e.g. you should write1000pt
rather than just1000
. The default value is70pt
. Here are two cruder plots with different values for this parameter:Adding a
samples
option works, but only up to a certain threshhold. Here is the case withsamples=100
which is as expected. If you change tosamples=131
then the label spacing changes, perhaps due to some overflow problem.samples=100
samples=131