Ich habe es endlich, dank der Antwort von @maij, mit der link er zur Verfügung gestellt.
Mit der Ausgabe Nummer , I @maij Linie mit diesem Parameter verwendet:
set cblabel "%" norotate offset -8, 12
Mit der Ausgabe Nummer , wenn die Heatmap Plotten, hatte ich von
plot "HeatMap_Test.txt" u 2:1:(step($3)) notitle pt 5 ps 2 lc palette
zu ändern
zu
plot "HeatMap_Test.txt" u 2:1:(step($3)) with image
Last, mit Ausgabenummer , die Etikett in den Konturlinien zu setzen, ich einen externen awk-Skript in den gleichen link wie bisher nutzen musste. Ich nannte das Skript draw_contourlines_label.sh, und der Inhalt des Skripts ist:
#!/bin/bash
awk -v d=$2 -v w=$3 -v os=$4 'function abs(x) { return (x>=0?x:-x) }
{
if($0~/# Contour/) nr=0
if(nr==int(os+w/2) && d==0) {a[i]=$1; b[i]=$2; c[i]=$3;}
if(nr==int(os+w/2)-1 && d==0) {i++; x = $1; y = $2;}
if(nr==int(os+w/2)+1 && d==0) r[i]= 180.0*atan2(y-$2, x-$1)/3.14
if(abs(nr-os-w/2)>w/2 && d==1) print $0
nr++
}
END { if(d==0) {
for(j=1;j<=i;j++)
printf "set label %d \"%g\" at %g, %g centre front rotate by %d\n", j, c[j], a[j], b[j], r[j]
}
}' "$1"
Dieses Skript hat die folgenden Parameter:
# 1 -> mit den Konturdaten erzeugt durch GNUplot Datei
# 2 -> Flagge. Wenn es "0" ist, wird ein Skript für GNUplot gedruckt, um die Beschriftungen im Diagramm hinzuzufügen.Wenn es ‚1‘ ist, nimmt die Punkte der Konturlinien aus, so dass die Linien der Kontur-Plots gehen nicht über das Etikett
# 3 -> Anzahl der Räume für die Formatierung des Etiketts
# 4 - > Offset die weißen Räume für die Etiketten zu bewegen (so sie nicht zentriert sind)
Mein Ergebnis wxt Terminal ist:
Das Ergebnis ist:
Der Code um den Plot zu erzeugen ist:
reset
#Function map values on desired ranges. The values set to 90,95,99 are for later labelling
step90(x) = (x < 20.0 ? 0 : (x < 50.0 ? 10 : (x < 75.0 ? 20 : (x < 90.0 ? 80 : (x < 95.0 ? 90 : (x < 97.5 ? 95 : (x < 99.0 ? 97 : (x < 99.5 ? 99 : (x < 99.9 ? 100 : 101)))))))))
# enable 3D data read from a scattered data set in file
#71,46,10 are the number of different values for each axis X,Y,Z in "HeatMap_Test.txt" data file
#If values of dgrid3d are not set accordingly, weird contour values will be generated
set dgrid3d 71,46,10
set contour base # enable contour drawing
set view 0,0 # if you want to see the graph from above (2D plot)
unset surface # do not plot the surface, only the contour
set cntrparam levels discrete 90,95,99 #set contours only on values 90,95 and 99
set table "contours.dat" #Name of the output file to write the table
splot "HeatMap_Test.txt" u 2:1:(step90($3)) notitle
unset table #Write table to file
reset
#Map the Z values to desired ranges
step(x) = (x < 20.0 ? 0 : (x < 50.0 ? 1 : (x < 75.0 ? 2 : (x < 90.0 ? 3 : (x < 95.0 ? 4 : (x < 97.5 ? 5 : (x < 99.0 ? 6 : (x < 99.5 ? 7 : (x < 99.9 ? 8 : 9)))))))))
set palette maxcolors 10
set palette defined (0 "#333399", 1 "#3333f7", 2 "#3373ff", 3 "#33c6ff", 4 "#5affd2", 5 "#9cff8f", 6 "#dfff4c", 7 "#ffc733", 8 "#ff7a33", 9 "#e53333")
set cbrange [-0.5:9.5]
set cbtics nomirror
set cbtics (">99.9" 9, ">99.5" 8, ">99.0" 7, ">97.5" 6, ">95.0" 5, ">90.0" 4, ">75.0" 3, ">50.0" 2, ">20.0" 1, ">10.0" 0)
set cblabel "%" norotate offset -8, 12
set xrange [-30:40]
set yrange [ 25:70]
set xtics 5
set ytics 5
set grid front linetype -1
set grid xtics lt 0 lw 1 lc rgb "#000000"
set grid ytics lt 0 lw 1 lc rgb "#000000"
load "<./draw_contourlines_label.sh contours.dat 0 4 0"
plot "HeatMap_Test.txt" u 2:1:(step($3)) with image, "world_10m.txt" notitle with lines ls 1 lc -1, "<./draw_contourlines_label.sh contours.dat 1 3 0" u 1:2 w l lw 2 lc 0 notitle
HINWEIS: Wenn die Datei „contours.dat“ mit GNUplot 4.6.4 berechnet wird, die Etiketten auf die gleiche Art und Weise nicht erscheinen. Sobald die Datei berechnet ist, wird in Version 4.6+ dieselbe Grafik angezeigt.
Wir können auch verwenden @maij Ansatz mit Splot-Funktion. Um dies zu tun, müssen wir zuerst die Schrittfunktion ändern, wie er sagte, weil es sonst merkwürdige Linien erzeugt. Ich benannte die Funktion step3D, aber es ist genau @maij oben gepostet:
step(x) = (x < 20.0 ? 0 : \
(x < 50.0 ? 10 : \
(x < 75.0 ? 20 : \
(x < 90.0 ? 80 : \
(x < 95.0 ? 89.999 : \
(x < 97.5 ? 94.999 : \
(x < 99.0 ? 97 : \
(x < 99.5 ? 98.999 : \
(x < 99.9 ? 100 : 101)))))))))
Mit splot, gibt es auch die Notwendigkeit, die Eingabedatei in Blöcke zu formatieren. Ich habe mit diesem einfachen awk-Skript, das direkt in dem splot Befehl gesetzt werden kann:
awk 'NF>=1 && $1!~/#/ && $1!=prev {print \"\"} {prev=$1;print}' HeatMap_Test.txt
In GNUplot 5+, beim Plotten der colobar Prozent erschienen Halb zerschnitt und die x- und y-Etikett wurden auch getrennt, so musste ich sie manuell optimieren, um den Bildschirm zu passen mit diesen Befehlen:
set rmargin at screen 0.8
set lmargin at screen 0.08
set tmargin at screen 0.95
set xtics offset 0, screen 0.036
set ytics offset screen 0.008, 0
die Konturlinien werden mit dem gleichen Befehl aufgetragen, so das Ergebnis, das wir bekommen, ist ähnlich (nur die Konturlinien auf Grund der etwas ändern Bereiche):
Der Code um den Plot zu erzeugen ist:
reset
#Function map values on desired ranges. The values set to 90,95,99 are for later labelling
step3D(x) = (x < 20.0 ? 0 : (x < 50.0 ? 10 : (x < 75.0 ? 20 : (x < 90.0 ? 80 : (x < 95.0 ? 89.999 : (x < 97.5 ? 94.999 : (x < 99.0 ? 97 : (x < 99.5 ? 98.999 : (x < 99.9 ? 100 : 101)))))))))
# enable 3D data read from a scattered data set in file
#71,46,10 are the number of different values for each axis X,Y,Z in "HeatMap_Test.txt" data file
#If values of dgrid3d are not set accordingly, weird contour values will be generated
set dgrid3d 71,46,10
set contour base # enable contour drawing
set view 0,0 # if you want to see the graph from above (2D plot)
unset surface # do not plot the surface, only the contour
set cntrparam levels discrete 90,95,99 #set contours only on values 90,95 and 99
set table "contours.dat" #Name of the output file to write the table
splot "HeatMap_Test.txt" u 2:1:(step3D($3)) notitle
unset table #Write table to file
reset
#Map the Z values to desired ranges
step(x) = (x < 20.0 ? 0 : (x < 50.0 ? 1 : (x < 75.0 ? 2 : (x < 90.0 ? 3 : (x < 95.0 ? 4 : (x < 97.5 ? 5 : (x < 99.0 ? 6 : (x < 99.5 ? 7 : (x < 99.9 ? 8 : 9)))))))))
set palette maxcolors 10
set palette defined (0 "#333399", 1 "#3333f7", 2 "#3373ff", 3 "#33c6ff", 4 "#5affd2", 5 "#9cff8f", 6 "#dfff4c", 7 "#ffc733", 8 "#ff7a33", 9 "#e53333")
set cbrange [-0.5:9.5]
set cbtics nomirror
set cbtics (">99.9" 9, ">99.5" 8, ">99.0" 7, ">97.5" 6, ">95.0" 5, ">90.0" 4, ">75.0" 3, ">50.0" 2, ">20.0" 1, ">10.0" 0)
set cblabel "%" norotate offset -8, 11.5
set xrange [-30:40]
set yrange [ 25:70]
set xtics 5
set ytics 5
set grid front linetype -1
set grid xtics lt 0 lw 1 lc rgb "#000000"
set grid ytics lt 0 lw 1 lc rgb "#000000"
set rmargin at screen 0.8
set lmargin at screen 0.08
set tmargin at screen 0.95
set xtics offset 0, screen 0.036
set ytics offset screen 0.008, 0
set pm3d explicit
set view map
load "<./draw_contourlines_label.sh contours.dat 0 4 0"
splot "< awk 'NF>=1 && $1!~/#/ && $1!=prev {print \"\"} {prev=$1;print}' HeatMap_Test.txt" u 2:1:(0):(step($3)) notitle w pm3d lc palette ,"world_10m.txt" u 1:2:(0) notitle with lines ls 1 lc rgb "#ffffff", "<./draw_contourlines_label.sh contours.dat 1 3 0" u 1:2:(0) w l lw 2 lc rgb "#000000" notitle
HINWEIS: Wenn Sie ein Windows-Benutzer sind, können Sie diese Handlung tun auch die GNUplot Version des Cygwin mit
, um die leeren Zeilen hinzufügen die Dateien, habe ich dieses Skript erstellt: '" < awk 'NF> = 1 && $ 1! ~/#/&& $ 1! = vorherige {print \ "} {prev = $ 1; print} 'HeatMap_Test.txt'' was sein kann direkt in GNUplot einfügen. Ich werde sehen, ob ich einen Weg finde, die Etiketten zu setzen. Danke. – AwkMan