You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Gnuplot中实现X轴标签顺时针45度旋转

解决Gnuplot X轴标签重叠并顺时针旋转45度的方法

要实现X轴标签从左端开始顺时针旋转45度,只需在脚本中添加X轴刻度旋转与对齐设置,同时调整底部边距避免标签被截断,具体修改如下:

修改后的完整脚本

reset session

$Data <<EOD
"Push-Front"            1604 0x289e37
"Push-Back"             218  0x289e37
"Insert"                873  0x289e37
"Push-Front-Collection" 439  0x289e37
"Push-Back-Collection"  261  0x289e37
"Insert-Collection"     254  0x289e37
"Search"                244  0x28579e
"Pop-Front"             3508 0xeb9534
"Pop-Back"              198  0xeb9534
"Delete"                3443 0xeb9534
"Delete-Range"          302  0xeb9534
EOD

set style fill solid 1.0
set boxwidth 0.8
set key noautotitle
set grid x,y
set tics out
# 添加X轴刻度旋转与对齐设置
set xtics rotate by -45 left
# 调整底部边距,避免旋转后的标签被截断
set bmargin 4
set terminal png size 450,300 enhanced font "Monospaced,13"
set output '..\msc-sandbox\TotalDurationBarPlotArrayList.png'
set yrange[0:4000]
set ylabel "Milliseconds"
plot $Data u 0:2:3:xtic(1) w boxes lc rgb var, \
        '' u 0:2:2 w labels offset 0,0.7

关键修改说明

  • set xtics rotate by -45 left:
    • rotate by -45:Gnuplot默认以逆时针为正方向,-45表示顺时针旋转45度;
    • left:设置标签的左端对齐到X轴刻度的正下方,实现“从左端开始旋转”的效果。
  • set bmargin 4:增大底部边距(数值为字符高度单位),防止旋转后的标签超出图片底部被截断。

内容的提问来源于stack exchange,提问作者coderodde

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 03:36:23