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

如何修改gnuplot中图例框的边框颜色?

调整gnuplot图例框颜色的方法

注意:你的原脚本中plot语句里的"Tree list缺少闭合双引号,运行前需要补上,否则会报错。

要调整图例框的颜色,只需在set key命令中添加边框颜色和可选的背景填充色参数即可,具体操作如下:

  • 修改set key命令,补充颜色控制参数
    比如要设置图例框边框为深蓝色、背景为浅灰色,修改后的set key命令如下:

    set key height 2 box left top linecolor rgb '#004488' bgcolor rgb '#eeeeee'
    
    • linecolor rgb '#004488':指定图例框的边框颜色,可替换为任意RGB值或颜色名称(如blue、red)
    • bgcolor rgb '#eeeeee':指定图例框的背景填充色,不需要填充背景的话可以去掉这个参数
  • 完整修改后的脚本示例

    set title font "Monospaced,13" 'Add at random spot'
    set grid
    set key height 2 box left top linecolor rgb '#004488' bgcolor rgb '#eeeeee'
    
    set style line 1 \
        linecolor rgb '#ff8844' \
        linetype 1 linewidth 3 \
        pointtype 5 pointsize 1.5
    
    set style line 2 \
        linecolor rgb '#22ff22' \
        linetype 1 linewidth 3 \
        pointtype 5 pointsize 1.5
    
    set xlabel 'Size'
    set ylabel 'Microseconds'
    set xrange [0:1000000]
    
    plot 'SO.dat' index 1 with linespoints linestyle 1 title "Indexed list", \
         ''       index 3 with linespoints linestyle 2 title "Tree list"
    
    set terminal png size 650,350 enhanced font "Monospaced,13"
    set output 'SO.png'
    replot
    exit
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 21:55:27