4

I would like to ask you about an advice in some specific problem with pgfplots routine. I tried to search any information on the internet, however with no satisfy reasults and that is the reason, why I am asking about the help.

My problem is as follow:

  • I ploted 3D surface plot with view as map (bellow is the example and code),
  • in "colorbar style" function I setup some cb settings,
  • picture is plotted via gnuplot external software,
  • because I need to setup the cb range for all (#hundreds) plots in the same range, I used point meta min/max, etc.
  • HOWEVER, the cb range does not correspond with real plotted situation on the presented picture. How to fix that problem?

    Thank you in advance for your help, Michal.

    data:

    X  Y  Z  2013-01-01 00:00:00
    48.0000  15.0000    2.1759    2.1859  =>  -0.0100 ** 2.2481 ==> -0.0723
    49.0000  14.0000    2.2063    2.2063  =>  -0.0000 ** 2.2481 ==> -0.0418 
    49.0000  15.0000    2.2133    2.2177  =>  -0.0043 ** 2.2481 ==> -0.0348 
    49.0000  16.0000    2.2542    2.2289  =>  0.0253 ** 2.2481 ==> 0.0061 
    50.0000  13.0000    2.2175    2.2261  =>  -0.0087 ** 2.2481 ==> -0.0306 
    50.0000  14.0000    2.2427    2.2375  =>  0.0052 ** 2.2481 ==> -0.0055
    50.0000  15.0000    2.2540    2.2488  =>  0.0052 ** 2.2481 ==> 0.0059
    50.0000  16.0000    2.2468    2.2601  =>  -0.0133 ** 2.2481 ==> -0.0013
    51.0000  14.0000    2.2808    2.2680  =>  0.0127 ** 2.2481 ==> 0.0326
    51.0000  15.0000    2.2788    2.2793  =>  -0.0006 ** 2.2481 ==> 0.0306
    51.0000  16.0000    2.2791    2.2906  =>  -0.0115 ** 2.2481 ==> 0.0310
    

    code:

    For example, the plotted value at the point [16,49] (showed in the fig) in real situation is characterised by ± 0.025, however according to presented cb range, its value is ± 0.06 ... And that is what I want to fix. I also tried to setup cbrange[-0.06:0.06] as gnuplot function, but that does not work as well.

    \documentclass{article}
    
    \usepackage{graphicx}
    \usepackage{pgfplots}
    \usepackage{tikz}
    \usepackage{textcomp}
    \usepackage{pgfplotstable}
    \usepackage{filecontents}
    \usepackage{gnuplottex}
    \usepgfplotslibrary{colormaps}
    \pgfplotsset{width=15cm,compat=1.5, colormap/cool}
    
    \usepgfplotslibrary{external}
    \tikzexternalize[prefix=test/]
    
    \begin{document}
    
    \tikzsetnextfilename{test0}
    
    \begin{tikzpicture}
    
     \begin{axis}[
      view={0}{90},
      title={$\textsc{\LARGE{GOPE 2013-01-01 00:00:00}}$},
      xlabel=$\textsc{Longitude [\textdegree]}$,
      ylabel=$\textsc{Latitude [\textdegree]}$,
      legend style={at={(0.5,-0.10)},
            anchor=north,legend columns=-1},
      ylabel style={sloped},
      xlabel style={sloped},
      xtick={13,14,15,16},
      ytick={48,49,50,51},
      colorbar,
      every colorbar/.append style={
      point meta min = -0.06,
      point meta max = 0.06,
      /pgf/number format/fixed,
      ylabel={\normalsize{Differences of input data and fitted regression plane\ [m]}},
      }
    ]%
    
    \addplot3 [surf] gnuplot [raw gnuplot]{
    set dgrid3d 50,50 spline;
    splot '2013-1-0' u 2:1:6;
     };
    \addplot3 [only marks, mark=*, mark size=3pt] table[x index=1, y index=0] {2013-1-0};
    \addplot [only marks, mark=oplus, mark size=3pt] coordinates {(14.7, 49.9)}; % GOPE
    
    \legend{ ,Fitted Grid Nodes, Receiver}
    \end{axis}
    \end{tikzpicture}
    \end{document} 
    

    FIG

    example

    edit

    Hi, Thanks for the answer and I just add my comment. In my opinion, data are correct and gnuplot as well. If I made a comment:

    %   every colorbar/.append style={
    %   point meta min = -0.06,
    %   point meta max =  0.06,
    %   /pgf/number format/fixed,
    %   ylabel={\normalsize{Differences of input data and fitted regression plane\     [m]}},
    %   }
    

    I get the colorbas as can be expected. But, what I need is to unify the range of all colorbars. For example, on fig. 3, you can see the range +/- [-0.03:0.025] and first two pics have [-0.02:0.025]. And I need the same one and of course the plots have to correspond to z-values of real data (6-th column in input file, as was showed above).

    Fig 1

    Figure 1

    Fig 2

    Figure 2

    Fig 3

    Figure 3

    Fig 4

    enter image description here

    • 1
      Please try to minimize your problem to the possible minimum! If possible, use filecontents and leave out the use of gnuplot (speaking of your MWE here). The point [16,49] is written as 0.0061 in your data file. But you want it to be +-0.025. The problem would be in your data or your gnuplot calculation then and therefore off-topic here. Please correct me, if I am wrong. – LaRiFaRi Apr 10 '15 at 8:46
    • 1
      Hi LaRiFaRi, please see my add comment! – Michal Apr 11 '15 at 10:36
    3

    The root cause for the inconsistency between colorbar and surface plot is that "point meta min" and "point meta max" are only specified within the color bar style, but not for the axis as such. The effect is that the colorbar's axis descriptions are overwritten, but the surface plot is entirely unaware of the modification.

    I do not know if the possibility to cause such inconsistencies is a bug or a feature in pgfplots - the intention behind such modifications is to allow full customization of the colorbar's axis descriptions.

    Anyway, the solution is to move "point meta min" and "point meta max" into the set of normal axis options, i.e.

    \documentclass{standalone}
    
    \usepackage{pgfplots}
    \usepackage{gnuplottex}
    \usepgfplotslibrary{colormaps}
    \pgfplotsset{width=15cm,compat=1.5, colormap/cool}
    
    \begin{document}
    
    \begin{tikzpicture}
    
     \begin{axis}[
      view={0}{90},
      xlabel={$\textsc{Longitude}$},
      ylabel={$\textsc{Latitude}$},
      legend style={at={(0.5,-0.10)},
            anchor=north,legend columns=-1},
      ylabel style={sloped},
      xlabel style={sloped},
      xtick={13,14,15,16},
      ytick={48,49,50,51},
      colorbar,
      point meta min = -0.06,
      point meta max = 0.06,
      every colorbar/.append style={
          /pgf/number format/fixed,
          ylabel={\normalsize{Differences of input data and fitted regression plane\ [m]}},
      }
    ]%
    
    \addplot3 [surf] gnuplot [raw gnuplot]{
    set dgrid3d 50,50 spline;
    splot '2013-1-0' u 2:1:6;
     };
    \addplot3 [only marks, mark=*, mark size=3pt] table[x index=1, y index=0] {2013-1-0};
    \addplot [only marks, mark=oplus, mark size=3pt] coordinates {(14.7, 49.9)}; % GOPE
    
    \legend{ ,Fitted Grid Nodes, Receiver}
    \end{axis}
    \end{tikzpicture}
    \end{document}
    

    This will result in consistent color codings ( by changing the appearance of the surface plot dramatically):

    enter image description here

    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.