使用gnuplot画图

本文详细介绍了如何通过步骤生成CWND图,包括准备cwnd.dat数据、编写cwnd.gnuplot脚本,设置参数如坐标范围、标签和图例,并最终通过gnuplot命令生成矢量图,可供后续转换。重点展示了如何设置参考线和柱状图元素。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

step1 准备数据cwnd.dat
step2 创建画图脚本cwnd.gnuplot
step3 写入cwnd.gnuplot

# 生成xx.eps矢量图,可以转换为.pdf等格式
set terminal postscript eps enhanced size 5, 4 color solid linewidth 3  # terminal postscript eps将图画到eps文件中; enhanced使用增强模式, size 5, 4 横纵比为5:4,color彩色图,solid实线,linewidth 3线(包括边框)的粗细为3磅 (front 'times, 32')
set output "dos.eps" # 输出图片名称

set xrang [-10:10] # x轴范围
set xlabel 'Time (ms)' # x轴标签
set xtics -10,2,10 # x轴增量为2

set yrang [-120:120] 
set ylabel 'Cwnd' offset 0.8, 0.0 # 将y轴标签移动(0.8,0.0)
set ytics -120,40,120 

# 设置画布尺寸
set bmargin at screen 0.18 # 图片框下面预留18%
set tmargin at screen 0.96 # 顶上留出4%
set lmargin at screen 0.18
set rmargin at screen 0.96

unset key # 删除图例
set arrow 1 from 0,-120 to 0,120 linestyle 0 nohead # 设置1号参考线, linestyle 0 虚线(1实线),没有箭头
plot "cwnd.dat" using 1:2 with lines linecolor '#FF0000' linewidth 2, "cwnd.dat" using 1:(-$3) with lines linecolor '#0000FF' linewidth 2 #using 1:2 使用数据的1,2行对应x,y, (-$3)第三列数据乘-1

step4 根据脚本画图,输入命令

gnuplot cwnd.gnuplot

step5 显示图片

evince dos.eps &

to-do

  • 参考线设置
  • 柱状图

参考

https://www.bilibili.com/video/BV1Vh411U7cK?spm_id_from=333.337.search-card.all.click

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值