1

The color of my diagram point is wrong if I look at my colorbar! What is the reason? The point should be not red! (Look at the scale of the colorbar)

This point: 0.63 3745 1000000

My Code:

\documentclass{article}
\usepackage{tikz,pgfplots} %Für die Darstellung
\begin{document}
\pgfmathdeclarefunction{lg10}{1}{ \pgfmathparse{ln(#1)/ln(10)}}
\begin{tikzpicture}
\begin{axis}[enlargelimits=0.2,set layers=standard, 
mark layer=axis background,colorbar sampled,only marks,view={0}{90}, colorbar style={yticklabel=\pgfmathparse{10^\tick}\pgfmathprintnumber\pgfmathresult,samples=20}] %Drehung
\addplot[
scatter,mark=square*,only marks,
point meta=\thisrow{myvalue}
]table {
x y  myvalue
0.2  100 1
0.35  2000 100
0.35  2000 100
0.63  3745 1000000
};
\end{axis}
\end{tikzpicture}
\end{document}
3
  • What do you mean with wrong? 1 and 100 is blue and 100000 is red -- looks ok to me. – Ulrike Fischer Mar 29 '18 at 12:35
  • @UlrikeFischer Fischer thx for your answer but look at the caption of the colorbar .... – user155964 Mar 29 '18 at 12:42
  • it should be red from 3,98*10 power of 6 not from 1000 000 – user155964 Mar 29 '18 at 12:42
1

Your code only changes the ticklabels at the colorbar.

Maybe you are looking for something like:

enter image description here

Code:

\documentclass{article}
\usepackage{pgfplots}% loads tikz too
\pgfplotsset{compat=newest}% <- added
\pgfmathdeclarefunction{lg10}{1}{ \pgfmathparse{ln(#1)/ln(10)}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[enlargelimits=0.2,set layers=standard, 
  mark layer=axis background,colorbar sampled,only marks,
  colorbar style={
    yticklabel=\pgfmathparse{10^(\tick-2)}\pgfmathprintnumber{\pgfmathresult},%<- changed
    scaled y ticks=manual: {$\cdot10^2$}{#1},%<- added
    samples=20
  }
]
\addplot[
  scatter,mark=square*,only marks,
  point meta=lg10(\thisrow{myvalue})%<- changed
]table {
x y  myvalue
0.2  100 1
0.35  2000 100
0.63  3745 1000000
};
\end{axis}
\end{tikzpicture}
\end{document}
1
  • Could you please repost your answer on TeXwelt? – Henri Menke Mar 31 '18 at 9:21
0

Are you sure you scale your values properly? Your declaration

\pgfmathdeclarefunction{lg10}{1}{ \pgfmathparse{ln(#1)/ln(10)}}

seems to have no effect whatsoever on the rest of your exemple (it can be commented out w/o giving an error or any visible change in the produced pdf). That usually means you have only declared the function, you are never using it.

2
  • ok your are right. But why is the last point red? Look at the log. scale of the colorbar. The value 1000000 is yellow/blue – user155964 Mar 29 '18 at 13:53
  • If you intend tu use a log_10, but you use a natural log, your values will be ln(10) or ~2.3 times too large. – remco Mar 29 '18 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.