我有这个 Gnuplot 脚本:
reset session
$Data <<EOD
"Push-Front" 2344 0x289e37
"Push-Back" 187 0x289e37
"Insert" 1222 0x289e37
"Push-Front-Collection" 519 0x289e37
"Push-Back-Collection" 420 0x289e37
"Insert-Collection" 287 0x289e37
"Search" 191 0x28579e
"Pop-Front" 4939 0xa83232
"Pop-Back" 251 0xa83232
"Delete" 4771 0xa83232
"Delete-Range" 345 0xa83232
EOD
set style line 11 lc rgb 0xeeeeee lt 1 lw 1
set style fill solid 1.0
set boxwidth 0.8
set key noautotitle
set ytics 1000
set grid y ls 11
set tics scale 0
set tics out
set xtics rotate by -45
set terminal svg size 450,300 enhanced font "Times New Roman,12"
set output '..\msc-sandbox\TotalDurationBarPlotArrayList.svg'
set yrange[0:5000]
set ylabel "Milliseconds"
plot $Data u 0:2:3:xtic(1) w boxes lc rgb var#, \
'' u 1:2:3 w labels offset 0,0.7
看起来像这样:
我想要实现的目标是在每个条形的顶部添加条形高度值,顺时针旋转 90 度,以便标签适合绘图。
你没有把自己的价值观放在首位
w boxes lc rgb var#, \
结束该行,其中 #, \
注释掉了以下行u 0:2:2
right
或 left
。这只是个人阅读偏好的问题。脚本:
### bar chart with rotated xticlabels and values on top
reset session
$Data <<EOD
"Push-Front" 2344 0x289e37
"Push-Back" 187 0x289e37
"Insert" 1222 0x289e37
"Push-Front-Collection" 519 0x289e37
"Push-Back-Collection" 420 0x289e37
"Insert-Collection" 287 0x289e37
"Search" 191 0x28579e
"Pop-Front" 4939 0xa83232
"Pop-Back" 251 0xa83232
"Delete" 4771 0xa83232
"Delete-Range" 345 0xa83232
EOD
set style line 11 lc rgb 0xeeeeee lt 1 lw 1
set style fill solid 1.0
set boxwidth 0.8
set key noautotitle
set ytics 1000
set grid y ls 11
set tics out
set xtics rotate by 45 right
set yrange[0:]
set ylabel "Milliseconds"
set offset 0,0, graph 0.1, 0
plot $Data u 0:2:3:xtic(1) w boxes lc rgb var, \
'' u 0:2:2 w labels offset 0,0.5 rotate by 90 left
### end of script
结果: