1

Is it possible to get a logarthmic colorbar?

\documentclass{article}

\usepackage{tikz,pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[enlargelimits=0.2,colorbar]
\addplot[
scatter,mark=square*,only marks,
point meta=\thisrow{myvalue}
]
table {
x y  myvalue
0.5  1 0.25
0.2  2 3
0.7  3 0.75
0.35  4 0.125
0.65  5 2
};
\end{axis}
\end{tikzpicture}

\end{document}

Solution?->

\documentclass{article}

\usepackage{tikz,pgfplots}

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

\begin{axis}[enlargelimits=0.2,colorbar, colorbar style={yticklabel=\pgfmathparse{10^\tick}\pgfmathprintnumber\pgfmathresult}]

\addplot[
scatter,mark=square*,only marks,
point meta=\thisrow{myvalue}
]
table {
x y  myvalue
0.5  100 554
0.2  2000 3546546
0.7  3745 0.755
0.35  74 0.125
0.65  775 2555
};
\end{axis}
\end{tikzpicture}

\end{document}

This is the solution? is this logaritmic? Looks linear

josef
  • 11
  • Welcome to TeX.SX! Yes it is: https://tex.stackexchange.com/a/267144/124842, https://tex.stackexchange.com/q/23750/124842. – Bobyandbob Jul 11 '17 at 12:41
  • i dont understand the solution... can somebody explain this to me with my example? thank you in advance – josef Jul 11 '17 at 12:54
  • Add this to your preamble: \pgfmathdeclarefunction{lg10}{1}{ \pgfmathparse{ln(#1)/ln(10)}} and then set your axis optional argument to [enlargelimits=0.2,colorbar, colorbar style={yticklabel=\pgfmathparse{10^\tick}\pgfmathprintnumber\pgfmathresult}] – Steven B. Segletes Jul 11 '17 at 12:59
  • \documentclass{article}

    \usepackage{tikz,pgfplots}

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

    \begin{axis}[enlargelimits=0.2,colorbar, colorbar style={yticklabel=\pgfmathparse{10^\tick}\pgfmathprintnumber\pgfmathresult}]

    \addplot[ scatter,mark=square*,only marks, point meta=\thisrow{myvalue} ] table { x y myvalue 0.5 100 554 0.2 2000 3546546 0.7 3745 0.755 0.35 74 0.125 0.65 775 2555 }; \end{axis} \end{tikzpicture}

    \end{document}

    – josef Jul 11 '17 at 13:16
  • @steven can you look at my solution? for me it looks linear – josef Jul 11 '17 at 13:19
  • When I compile your solution, I get a logarithmic colorbar, as you had asked for, with a scale of (1,10,100,1000)x10^6. The axes are linear, but you did not ask for log axes, but a log colorbar. – Steven B. Segletes Jul 11 '17 at 13:22

0 Answers0