2

For the set of data here, the following code can't compile showing the error

Package pgfplots Error: CRITICAL: shader=interp: got unsupported pdf shading type '0'. This may corrupt your pdf!.

\documentclass[border= 5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
    \begin{tikzpicture}
    \begin{axis}[unbounded coords=jump, view={70}{40}]
    \addplot3 [surf,shader=interp] 
    table [x index={0}, y index={1}, col sep=tab] {mySurfaceData.txt};
    \end{axis}
    \end{tikzpicture}
\end{document} 

So, what went wrong to cause this?

P.S. the original data without NaN is available here, where I would like to skip plotting those points of z=1.

  • Something is probably wrong with your data file unequal rows or groups etc. EDIT Actually probably due to some cells are being NaN cannot be shaded. – percusse Aug 4 '18 at 8:27
  • @percusse Alright, after checking my data, here you can find the raw data without NaN where I would like to skip plotting those points of z>=1. Additionally, the same data is available here while replacing the z values of the points to skip with NaN. – Diaa Aug 4 '18 at 10:36
3

The main issue is that you have to leave one empty line per group in your data such as this

0   0   1
0   0.2 1
0   0.4 1
0   0.6 1
0   0.8 1
0   1   1
0   1.2 1
0   1.4 1
0   1.6 1
0   1.8 1
0   2   1
0   2.2 1
0   2.4 1
0   2.6 1
0   2.8 1
0   3   1
0   3.2 1
0   3.4 1
0   3.6 1
0   3.8 1
0   4   1
0   4.2 1
0   4.4 1
0   4.6 1
0   4.8 1
0   5   1
0   5.2 1
0   5.4 1
0   5.6 1
0   5.8 1
0   6   1

0.2 0   1
0.2 0.2 1
0.2 0.4 1
0.2 0.6 1
0.2 0.8 1
0.2 1   1
0.2 1.2 1
0.2 1.4 1
0.2 1.6 1
0.2 1.8 1
0.2 2   1
0.2 2.2 1
0.2 2.4 1
0.2 2.6 1
0.2 2.8 1
0.2 3   1
0.2 3.2 1
0.2 3.4 1
0.2 3.6 1
0.2 3.8 1
0.2 4   1
0.2 4.2 1
0.2 4.4 1
0.2 4.6 1
0.2 4.8 1
0.2 5   1
0.2 5.2 1
0.2 5.4 1
0.2 5.6 1
0.2 5.8 1
0.2 6   1

0.4 0   1
0.4 0.2 1
0.4 0.4 1
0.4 0.6 1
0.4 0.8 1
0.4 1   1
0.4 1.2 1
0.4 1.4 1
0.4 1.6 1
0.4 1.8 1
0.4 2   1
0.4 2.2 1
0.4 2.4 1
0.4 2.6 1
0.4 2.8 1
0.4 3   1
0.4 3.2 1
0.4 3.4 1
0.4 3.6 1
0.4 3.8 1
0.4 4   1
0.4 4.2 1
0.4 4.4 1
0.4 4.6 1
0.4 4.8 1
0.4 5   1
0.4 5.2 1
0.4 5.4 1
0.4 5.6 1
0.4 5.8 1
0.4 6   1

0.6 0   1
0.6 0.2 1
0.6 0.4 1
0.6 0.6 1
0.6 0.8 1
0.6 1   1
0.6 1.2 1
0.6 1.4 1
0.6 1.6 1
0.6 1.8 1
0.6 2   1
0.6 2.2 1
0.6 2.4 1
0.6 2.6 1
0.6 2.8 1
0.6 3   1
0.6 3.2 1
0.6 3.4 1
0.6 3.6 1
0.6 3.8 1
0.6 4   1
0.6 4.2 1
0.6 4.4 1
0.6 4.6 1
0.6 4.8 1
0.6 5   1
0.6 5.2 1
0.6 5.4 1
0.6 5.6 1
0.6 5.8 1
0.6 6   1

0.8 0   1
0.8 0.2 1
0.8 0.4 1
0.8 0.6 1
0.8 0.8 1
0.8 1   1
0.8 1.2 1
0.8 1.4 1
0.8 1.6 1
0.8 1.8 1
0.8 2   1
0.8 2.2 1
0.8 2.4 1
0.8 2.6 1
0.8 2.8 1
0.8 3   1
0.8 3.2 1
0.8 3.4 1
0.8 3.6 1
0.8 3.8 1
0.8 4   1
0.8 4.2 1
0.8 4.4 1
0.8 4.6 1
0.8 4.8 1
0.8 5   1
0.8 5.2 1
0.8 5.4 1
0.8 5.6 1
0.8 5.8 1
0.8 6   1

1   0   0.29788
1   0.2 0.30895
1   0.4 0.35928
1   0.6 0.39989
1   0.8 0.47275
1   1   0.54074
1   1.2 0.61324
1   1.4 0.68626
1   1.6 0.76031
1   1.8 0.83381
1   2   0.9063
1   2.2 0.97466
1   2.4 1
1   2.6 1
1   2.8 1
1   3   1
1   3.2 1
1   3.4 1
1   3.6 1
1   3.8 1
1   4   1
1   4.2 1
1   4.4 1
1   4.6 1
1   4.8 1
1   5   1
1   5.2 1
1   5.4 1
1   5.6 1
1   5.8 1
1   6   1

1.2 0   0.27341
1.2 0.2 0.28421
1.2 0.4 0.31272
1.2 0.6 0.34844
1.2 0.8 0.39602
1.2 1   0.44535
1.2 1.2 0.49852
1.2 1.4 0.55192
1.2 1.6 0.6059
1.2 1.8 0.65859
1.2 2   0.70699
1.2 2.2 0.74459
1.2 2.4 0.73362
1.2 2.6 0.69729
1.2 2.8 0.67237
1.2 3   0.65348
1.2 3.2 0.63706
1.2 3.4 0.62313
1.2 3.6 0.61008
1.2 3.8 0.59822
1.2 4   0.58657
1.2 4.2 0.57648
1.2 4.4 0.56575
1.2 4.6 0.55533
1.2 4.8 0.54409
1.2 5   0.53197
1.2 5.2 0.51934
1.2 5.4 0.50581
1.2 5.6 0.49314
1.2 5.8 0.48142
1.2 6   0.47648

1.4 0   0.22609
1.4 0.2 0.24507
1.4 0.4 0.2699
1.4 0.6 0.29933
1.4 0.8 0.33498
1.4 1   0.37259
1.4 1.2 0.41242
1.4 1.4 0.45264
1.4 1.6 0.49292
1.4 1.8 0.53174
1.4 2   0.5669
1.4 2.2 0.59357
1.4 2.4 0.60377
1.4 2.6 0.59853
1.4 2.8 0.58862
1.4 3   0.57911
1.4 3.2 0.57091
1.4 3.4 0.5633
1.4 3.6 0.55599
1.4 3.8 0.549
1.4 4   0.54192
1.4 4.2 0.53496
1.4 4.4 0.5274
1.4 4.6 0.51927
1.4 4.8 0.5101
1.4 5   0.49983
1.4 5.2 0.48858
1.4 5.4 0.47657
1.4 5.6 0.46494
1.4 5.8 0.45504
1.4 6   0.4531

1.6 0   0.18784
1.6 0.2 0.20785
1.6 0.4 0.23097
1.6 0.6 0.2565
1.6 0.8 0.2851
1.6 1   0.31477
1.6 1.2 0.34563
1.6 1.4 0.37656
1.6 1.6 0.4073
1.6 1.8 0.43682
1.6 2   0.46384
1.6 2.2 0.48594
1.6 2.4 0.50064
1.6 2.6 0.50704
1.6 2.8 0.5097
1.6 3   0.51008
1.6 3.2 0.50927
1.6 3.4 0.50789
1.6 3.6 0.50601
1.6 3.8 0.5037
1.6 4   0.50079
1.6 4.2 0.49728
1.6 4.4 0.49278
1.6 4.6 0.48718
1.6 4.8 0.48016
1.6 5   0.4716
1.6 5.2 0.46157
1.6 5.4 0.45029
1.6 5.6 0.43852
1.6 5.8 0.42723
1.6 6   0.4175

1.8 0   0.15269
1.8 0.2 0.17483
1.8 0.4 0.19767
1.8 0.6 0.22088
1.8 0.8 0.24519
1.8 1   0.26963
1.8 1.2 0.29434
1.8 1.4 0.31875
1.8 1.6 0.34282
1.8 1.8 0.36603
1.8 2   0.38783
1.8 2.2 0.40719
1.8 2.4 0.42333
1.8 2.6 0.43598
1.8 2.8 0.44503
1.8 3   0.45159
1.8 3.2 0.45654
1.8 3.4 0.46027
1.8 3.6 0.463
1.8 3.8 0.46479
1.8 4   0.46558
1.8 4.2 0.46526
1.8 4.4 0.46363
1.8 4.6 0.46044
1.8 4.8 0.45542
1.8 5   0.44839
1.8 5.2 0.43927
1.8 5.4 0.42821
1.8 5.6 0.41556
1.8 5.8 0.40195
1.8 6   0.38749

2   0   0.12467
2   0.2 0.14823
2   0.4 0.17143
2   0.6 0.19242
2   0.8 0.21449
2   1   0.23524
2   1.2 0.2557
2   1.4 0.27544
2   1.6 0.29479
2   1.8 0.31362
2   2   0.33205
2   2.2 0.34976
2   2.4 0.36639
2   2.6 0.38143
2   2.8 0.39438
2   3   0.40525
2   3.2 0.41445
2   3.4 0.42221
2   3.6 0.42863
2   3.8 0.4338
2   4   0.43767
2   4.2 0.44018
2   4.4 0.44105
2   4.6 0.44007
2   4.8 0.43687
2   5   0.43117
2   5.2 0.42277
2   5.4 0.41163
2   5.6 0.39782
2   5.8 0.38181
2   6   0.36345

Then pgfplots understands the mesh properties otherwise it takes it as a one big patch. After that you can use anything you want. Here is an example

\documentclass[border= 5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
  \begin{tikzpicture}
    \begin{axis}[unbounded coords=jump, view={70}{40},colormap/viridis]
    \addplot3 [surf,shader=faceted] table {mySurfaceData.txt};
    \end{axis}
  \end{tikzpicture}
\end{document}

I would really suggest not using tab separated documents as they usually get lost in the file encodings and also annoying for different editors.

enter image description here

If you want to skip certain levels add restrict z to domain=0:0.999 but then you will loose the patch corners and number of patches will be decreased. There is no way to cut patches into parts either on or off.

  • Thanks for your answer, but is it not possible to follow the same approach of the answer to my previous question where I was able to produce a conditional plot? – Diaa Aug 4 '18 at 11:31
  • 1
    @Diaa You can. But you need to have the empty lines – percusse Aug 4 '18 at 11:35

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.