我有一个等高线图,其中的数据似乎没有被适当绘制。
\documentclass[crop,tikz]{standalone}%
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.15,
}
\usepgfplotslibrary{patchplots}
\usepackage{filecontents}
\begin{filecontents*}{table.dat}
0 0 2.000400080016007
0 20 0
0 40 0
0 60 0
0 80 0
0 100 0
0 120 0
0 140 0
0 160 0
0 180 0
0 200 0
0 220 0
0 240 0
0 260 0
0 280 0
0 300 0
0 320 0
0 340 0
0 360 0
0 380 0
0 400 0
0 420 0
0 440 0
0 460 0
0 480 0
0 500 0
5 0 1.160696417850715
5 20 0
5 40 0
5 60 0
5 80 0
5 100 0
5 120 0
5 140 0
5 160 0
5 180 0
5 200 0
5 220 0
5 240 0
5 260 0
5 280 0
5 300 0
5 320 0
5 340 0
5 360 0
5 380 0
5 400 0
5 420 0
5 440 0
5 460 0
5 480 0
5 500 0
10 0 0.48028817290374226
10 20 0
10 40 0
10 60 0
10 80 0
10 100 0
10 120 0
10 140 0
10 160 0
10 180 0
10 200 0
10 220 0
10 240 0
10 260 0
10 280 0
10 300 0
10 320 0
10 340 0
10 360 0
10 380 0
10 400 0
10 420 0
10 440 0
10 460 0
10 480 0
10 500 0
15 0 0.5003001801080598
15 20 0
15 40 0
15 60 0
15 80 0
15 100 0
15 120 0
15 140 0
15 160 0
15 180 0
15 200 0
15 220 0
15 240 0
15 260 0
15 280 0
15 300 0
15 320 0
15 340 0
15 360 0
15 380 0
15 400 0
15 420 0
15 440 0
15 460 0
15 480 0
15 500 0
20 0 0.5201040208041574
20 20 0
20 40 0
20 60 0
20 80 0
20 100 0
20 120 0
20 140 0
20 160 0
20 180 0
20 200 0
20 220 0
20 240 0
20 260 0
20 280 0
20 300 0
20 320 0
20 340 0
20 360 0
20 380 0
20 400 0
20 420 0
20 440 0
20 460 0
20 480 0
20 500 0
25 0 0.9803921568627416
25 20 0
25 40 0
25 60 0
25 80 0
25 100 0
25 120 0
25 140 0
25 160 0
25 180 0
25 200 0
25 220 0
25 240 0
25 260 0
25 280 0
25 300 0
25 320 0
25 340 0
25 360 0
25 380 0
25 400 0
25 420 0
25 440 0
25 460 0
25 480 0
25 500 0
30 0 2.360472094418886
30 20 0
30 40 0
30 60 0
30 80 0
30 100 0
30 120 0
30 140 0
30 160 0
30 180 0
30 200 0
30 220 0
30 240 0
30 260 0
30 280 0
30 300 0
30 320 0
30 340 0
30 360 0
30 380 0
30 400 0
30 420 0
30 440 0
30 460 0
30 480 0
30 500 0
35 0 14.942988597719541
35 20 0
35 40 0
35 60 0
35 80 0
35 100 0
35 120 0
35 140 0
35 160 0
35 180 0
35 200 0
35 220 0
35 240 0
35 260 0
35 280 0
35 300 0
35 320 0
35 340 0
35 360 0
35 380 0
35 400 0
35 420 0
35 440 0
35 460 0
35 480 0
35 500 0
40 0 28.6972183309986
40 20 0
40 40 0
40 60 0
40 80 0
40 100 0
40 120 0
40 140 0
40 160 0
40 180 0
40 200 0
40 220 0
40 240 0
40 260 0
40 280 0
40 300 0
40 320 0
40 340 0
40 360 0
40 380 0
40 400 0
40 420 0
40 440 0
40 460 0
40 480 0
40 500 0
45 0 34.78783026421137
45 20 0
45 40 0
45 60 0
45 80 0
45 100 0
45 120 0
45 140 0
45 160 0
45 180 0
45 200 0
45 220 0
45 240 0
45 260 0
45 280 0
45 300 0
45 320 0
45 340 0
45 360 0
45 380 0
45 400 0
45 420 0
45 440 0
45 460 0
45 480 0
45 500 0
50 0 39.771817453963166
50 20 0
50 40 0
50 60 0
50 80 0
50 100 0
50 120 0
50 140 0
50 160 0
50 180 0
50 200 0
50 220 0
50 240 0
50 260 0
50 280 0
50 300 0
50 320 0
50 340 0
50 360 0
50 380 0
50 400 0
50 420 0
50 440 0
50 460 0
50 480 0
50 500 0
55 0 47.28837302381429
55 20 0
55 40 0
55 60 0
55 80 0
55 100 0
55 120 0
55 140 0
55 160 0
55 180 0
55 200 0
55 220 0
55 240 0
55 260 0
55 280 0
55 300 0
55 320 0
55 340 0
55 360 0
55 380 0
55 400 0
55 420 0
55 440 0
55 460 0
55 480 0
55 500 0
60 0 62.3124624924985
60 20 0.22022022022022414
60 40 0
60 60 0
60 80 0
60 100 0
60 120 0
60 140 0
60 160 0
60 180 0
60 200 0
60 220 0
60 240 0
60 260 0
60 280 0
60 300 0
60 320 0
60 340 0
60 360 0
60 380 0
60 400 0
60 420 0
60 440 0
60 460 0
60 480 0
60 500 0
65 0 74.25940752602081
65 20 0.26026026026025884
65 40 0.020016012810253336
65 60 0
65 80 0
65 100 0
65 120 0
65 140 0
65 160 0
65 180 0
65 200 0
65 220 0
65 240 0
65 260 0
65 280 0
65 300 0
65 320 0
65 340 0
65 360 0
65 380 0
65 400 0
65 420 0
65 440 0
65 460 0
65 480 0
65 500 0
70 0 79.45589117823565
70 20 1.6012810248198561
70 40 0.08006405124099114
70 60 0.02000400080015563
70 80 0
70 100 0
70 120 0
70 140 0
70 160 0
70 180 0
70 200 0
70 220 0
70 240 0
70 260 0
70 280 0
70 300 0
70 320 0
70 340 0
70 360 0
70 380 0
70 400 0
70 420 0
70 440 0
70 460 0
70 480 0
70 500 0
75 0 86.93477390956382
75 20 7.301460292058415
75 40 1.9619619619619666
75 60 0.7201440288057581
75 80 0.4604604604604656
75 100 0.16009605763458445
75 120 0.08001600320064473
75 140 0.02000800320127727
75 160 0.02000800320127727
75 180 0.020012007204317506
75 200 0.020012007204317506
75 220 0.020012007204317506
75 240 0
75 260 0
75 280 0
75 300 0
75 320 0
75 340 0
75 360 0
75 380 0
75 400 0
75 420 0
75 440 0
75 460 0
75 480 0
75 500 0
80 0 91.47829565913183
80 20 13.165266106442575
80 40 7.703081232492992
80 60 5.484387510008004
80 80 4.02080416083217
80 100 3.220644128825767
80 120 2.8411364545818274
80 140 2.601040416166467
80 160 1.8021625951141318
80 180 1.8603720744148844
80 200 1.3605442176870763
80 220 1.241489787745298
80 240 1.0806483890334229
80 260 1.040208041608326
80 280 0.9603841536614643
80 300 0.860860860860857
80 320 1.00040016006403
80 340 0.8001600320064028
80 360 0.7204322593556078
80 380 0.5404323458767069
80 400 0.48067294211896483
80 420 0.4003202562049668
80 440 0.200080032012806
80 460 0.4601840736294549
80 480 0.3800760152030458
80 500 0.46027616569942476
85 0 94.21884376875374
85 20 22.03321993195918
85 40 12.264905962384953
85 60 9.263705482192874
85 80 7.78155631126225
85 100 7.145716573258609
85 120 5.841168233646732
85 140 5.584467574059248
85 160 5.321064212842563
85 180 4.90196078431373
85 200 4.520904180836172
85 220 4.520904180836172
85 240 4.740948189637928
85 260 4.181672669067627
85 280 3.8007601520304024
85 300 3.923923923923922
85 320 3.7222333400039997
85 340 3.640728145629124
85 360 3.3806761352270454
85 380 3.5007001400280013
85 400 3.3633633633633586
85 420 3.141256502601042
85 440 3.0218130878527094
85 460 2.7005401080216096
85 480 3.0224179343474766
85 500 2.901741044626771
90 0 95.75915183036608
90 20 33.13325330132053
90 40 22.168867547018813
90 60 18.170902541524914
90 80 15.835835835835832
90 100 13.985594237695075
90 120 12.782556511302257
90 140 12.027216329797874
90 160 10.024009603841533
90 180 10.864345738295322
90 200 9.601920384076813
90 220 8.805283169901944
90 240 8.30332132853141
90 260 8.641728345669131
90 280 7.74464678807284
90 300 7.401480296059216
90 320 7.923169267707086
90 340 7.488986784140971
90 360 6.742697078831528
90 380 6.8254603682946335
90 400 6.242496998799519
90 420 6.761352270454091
90 440 6.4051240992794245
90 460 6.841368273654735
90 480 5.542216886754703
90 500 6.162464985994398
95 0 97.47949589917984
95 20 42.997198879551824
95 40 31.81909145487293
95 60 28.665733146629325
95 80 25.690276110444177
95 100 22.83370022013208
95 120 21.73303982389434
95 140 20.12012012012012
95 160 18.60744297719088
95 180 18.687474989996
95 200 17.363472694538906
95 220 17.18687474989996
95 240 16.643328665733147
95 260 15.606242496998801
95 280 15.395395395395395
95 300 14.811849479583671
95 320 15.398478173808572
95 340 14.165666266506605
95 360 14.943910256410254
95 380 14.522904580916185
95 400 14.068441064638781
95 420 13.568140884530722
95 440 13.4453781512605
95 460 12.70508203281312
95 480 13.522704540908181
95 500 13.265306122448983
100 0 98.33966793358671
100 20 52.041633306645316
100 40 43.17727090836334
100 60 38.21528611444578
100 80 34.90792634107286
100 100 32.0328131252501
100 120 30.550550550550547
100 140 29.372871168102588
100 160 29.040656919687557
100 180 27.09083633453382
100 200 26.485297059411884
100 220 25.825165033006602
100 240 25.245049009801956
100 260 25.415249149489693
100 280 24.16966786714686
100 300 25.27516509905944
100 320 22.864572914582915
100 340 23.024604920984192
100 360 22.08883553421368
100 380 22.246696035242287
100 400 23.324664932986593
100 420 22.98919567827131
100 440 21.024204840968196
100 460 20.92837134853942
100 480 21.87750200160128
100 500 19.603524229074885
\end{filecontents*}
\begin{document}
% \newcounter{plotno}
% \begin{document}
\centering
\begin{tikzpicture}
\newcounter{plotno}
\begin{axis}[set layers,
xlabel={Dispersion},
ylabel={Extra slots},
xmin=0,
ymin=0,
ymax=400,
title={Percentage of incomplete blocks},
small,view={0}{90},colorbar,
% to eliminate the frame and keep the tics and labels
axis line style={draw=none},
tick style={draw=none},
% and remove the line of the colorbar
colorbar style={ axis line style={draw=none},
},
% colormap/viridis,
]
\setcounter{plotno}{-1}
% \pgfplotsinvokeforeach{0, 2.5, 5, 7.25, 10,12.5, 15,17.5 , 20,22.5, 25,27.5, 30,32.5, 35,37.5, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100}
\pgfplotsinvokeforeach{0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}
{\addplot3 [ patch type=bilinear,
point meta=z,
point meta max = 1,
point meta min =0,
contour gnuplot={labels=false,
levels = {#1}
}]
table {table.dat};
\stepcounter{plotno}
\addplot[contour prepared={labels=false,filled},fill=mapped color] table
{\jobname_contourtmp\number\value{plotno}.table} coordinate[pos=0](p\number\value{plotno}-start)
coordinate[pos=1](p\number\value{plotno}-end)
[insert path={(p\number\value{plotno}-end)-|(p\number\value{plotno}-start)}];
}
\pgfplotsonlayer{axis background}
\pgfplotscolormapdefinemappedcolor{0}
\fill[mapped color] (current axis.south west) rectangle
(current axis.north east);
\endpgfplotsonlayer
\end{axis}
\end{tikzpicture}
\end{document}
当第一列为dispersion
40 或 50 且第二列extra slots
> 0 时,第三列(函数)为零。但是,图表显示非零值。
使用 Matlab 绘制数据文件:
该图与数据相对应。
我希望使用pgfplots
或获得与 Matlab 相同的结果TikZ
。
问候
编辑
带标签的 Matlab 图为: