我有一个感兴趣的化合物的红外光谱,我想绘制它,并且我有一个包含所有数据点的 spectrum.dat 文件。它的形式如下:
# X Y
300 100
301 100
302 99
303 70
...
3999 98
4000 100
我想使用红外光谱的典型 x 轴来绘制此图,但我在这样做时遇到了困难。 If you are unfamiliar, this is what a typical IR spectrum might look like (除了图表本身上的标签)。请注意,x 轴是反向的,并且在超过 2000 单位(厘米的倒数)时,它的缩放比例突然加倍。有没有办法强制 Gnuplot 以这种方式绘制我的数据?到目前为止,我已经设法想出以下脚本:
# Make an SVG of size 800x500
set terminal svg size 800,500 fname 'CMU Sans Serif' fsize '10'
set output 'ir.svg'
# Color definitions
set border linewidth 1.5
set style line 1 lc rgb '#a0a0a0' lt 1 lw 2 pt 7 # gray
# Format graph
unset key
set xlabel 'Wavenumbers'
set ylabel 'Transmittance'
set xrange [4000:300]
# Plot data
plot 'spectrum.dat' with lines ls 1
这很好地反转了 x 轴,但我不知道如何以如此不寻常的方式更改缩放比例。
最佳答案
作为一名化学家,我有动力回答......
据我所知,gnuplot 不容易允许任意轴缩放(除非有人对如何使用 set link
有好主意)。在这种情况下,我的策略是分别绘制两半并让它们无缝连接:
#!/usr/bin/env gnuplot
set terminal png size 800,500
set output 'ir.png'
set xlabel 'Wavenumbers' offset 20
set ylabel 'Transmittance'
set tics out nomirror
set key bottom right
set bmargin 4
set yrange [0:1]
set multiplot layout 1,2 title 'IR Spectrum of Cholesterol'
# left half of plot
set xrange [4000:2000]
set rmargin 0
set border 7
plot 'cholesterol.txt' notitle
# right half of plot
set xrange [1999:300]
set lmargin 0
set rmargin 2
set border 13
unset xlabel
unset ylabel
unset ytics
plot 'cholesterol.txt' title 'Cholesterol'
unset multiplot
我的一个小问题是,2000
被写了两次,在我的屏幕上看起来更大胆,但我会把烦躁的问题留给你。
关于使用 Gnuplot 绘制红外光谱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23772026/