3

I'm trying to make a heat map of matrix form data, with logarithmic scale on the colorbar, I'm essentially following the advice here. But the problem I am having is that I have the ticks set on weird places (not integer powers of ten). I have tried to reconcile this setting the ticks myself with an adaptation from this example. Code:

\begin{tikzpicture}
\begin{axis}[colormap={bw}{gray(0cm)=(0); gray(1cm)=(1)},view={0}{90},xlabel=$\Delta \omega$,ylabel=$\alpha$,colorbar,colorbar style={ytick={-6,-5,-4,-3,-2,-1,0},yticklabel=\pgfmathparse{10^\tick}\pgfmathprintnumber\pgfmathresult}]
\addplot3[white, mark=*] coordinates{(10.9,21.8,0)};
\addplot3[surf,mesh/rows=5] coordinates{
(3.000000,10.000000,0.538205) (6.500000,10.000000,-0.550321) (10.000000,10.000000,-0.189491) (13.500000,10.000000,-0.124207) (17.000000,10.000000,-0.087244)
(3.000000,16.625000,0.676640) (6.500000,16.625000,-0.627121) (10.000000,16.625000,0.697299) (13.500000,16.625000,-0.557050) (17.000000,16.625000,0.250039)
(3.000000,23.250000,0.335725) (6.500000,23.250000,0.082835) (10.000000,23.250000,0.285066) (13.500000,23.250000,-0.224837) (17.000000,23.250000,-0.295350)
(3.000000,29.875000,0.470570) (6.500000,29.875000,-0.440295) (10.000000,29.875000,0.481443) (13.500000,29.875000,-0.431963) (17.000000,29.875000,0.117531)
(3.000000,36.500000,-0.317986) (6.500000,36.500000,-0.166810) (10.000000,36.500000,-0.146841) (13.500000,36.500000,-0.122043) (17.000000,36.500000,-0.149057)
};
\end{axis}
\end{tikzpicture}

But the for one reason or another the ticks do not appear at integer powers of ten:plot image

How would I go about getting the ticks where I want them?

1 Answers1

1

Your question is a bit confusing, because the data you provide don't result in the image you provided. Because your z data lay between -1 and 1 and so one can't apply a log to them, I assume, that they are already logarithmized.

If that is true you already had the right solution. Simply exchange yticklabel=\pgfmathparse{10^\tick}\pgfmathprintnumber\pgfmathresult} with yticklabel={$10^{\pgfmathprintnumber{\tick}}$}.

If your original data are not logarithmized already then have a look at the solution Jake has provided here.

I recommend also having a look at my answer given here, which explains the main differences between your and my attempt to solve the problem. (You are providing a 5x5 matrix, but your result only contains 4x4 "blocks" instead of 5x5 in mine. This behavior which might be intended by you, but it must not.)

% used PGFPlots v1.14
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{
        % just for improved positioning of the axis labels
        compat=1.3,
    }
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            enlargelimits=false,
            axis on top,
            colormap={bw}{gray(0cm)=(0); gray(1cm)=(1)},
            xlabel=$\Delta \omega$,
            ylabel=$\alpha$,
            colorbar,
            colorbar style={
%                % if you need/want to, provide the powers you want here
%                ytick={-1,0,1},
                yticklabel={$10^{\pgfmathprintnumber{\tick}}$},
            },
            point meta min=-1,
            point meta max=1,
        ]
            \addplot [white, mark=*] coordinates { (10.9,21.8) };
            \addplot [
                matrix plot*,
                point meta=explicit,
            ] table [
                x=x,
                y=y,
                meta=logz,
            ] {
                x       y       logz
                3.0     10.000  0.538205
                6.5     10.000  -0.550321
                10.0    10.000  -0.189491
                13.5    10.000  -0.124207
                17.0    10.000  -0.087244

                3.0     16.625  0.676640
                6.5     16.625  -0.627121
                10.0    16.625  0.697299
                13.5    16.625  -0.557050
                17.0    16.625  0.250039

                3.0     23.250  0.335725
                6.5     23.250  0.082835
                10.0    23.250  0.285066
                13.5    23.250  -0.224837
                17.0    23.250  -0.295350

                3.0     29.875  0.470570
                6.5     29.875  -0.440295
                10.0    29.875  0.481443
                13.5    29.875  -0.431963
                17.0    29.875  0.117531

                3.0     36.500  -0.317986
                6.5     36.500  -0.166810
                10.0    36.500  -0.146841
                13.5    36.500  -0.122043
                17.0    36.500  -0.149057
            };
        \end{axis}
    \end{tikzpicture}
\end{document}

image showing the result of above code

Stefan Pinnow
  • 29,535