【发布时间】:2013-09-07 14:17:51
【问题描述】:
我在 Gnuplot 中绘制了以下内容。我的问题是曲线超出了边界(所以我们可以看到紫色和蓝色曲线超出了 y 轴)。有什么办法可以解决这个问题?我希望有一些东西将绘图限制在绘图区域内。当然,我可以绘制更少的曲线,但这看起来很奇怪。理想情况下,我希望 Gnuplot 绕过曲线的框架并删除那里的曲线。
为了说明问题,我将紫色曲线弄得异常肥大。不过,蓝色曲线也存在问题。
产生上述情节的代码是:
#!/usr/bin/env gnuplot
### n: change this parameter to equal the number of data sets to be plotted
n = 2
# t: top margin in pixels
t = 25.0
# b: key height in pixels (bottom margin)
b = 25.0
# h: height of output in pixels
h = 150.0*n + t + b
### define functions to help set top/bottom margins
top(i,n,h,t,b) = 1.0 - (t+(h-t-b)*(i-1)/n)/h
bot(i,n,h,t,b) = 1.0 - (t+(h-t-b)*i/n)/h
### first set up some basic plot parameters
#set term cairolatex size 15cm,15cm
#set output 'DifferentialAmplifierPlot.tex'
set term pdfcairo size 15cm,15cm
set output 'DifferentialAmplifierPlot.pdf'
set border lw 4
set grid mxtics mytics xtics ytics ls '-1' ls '-1' lc rgb 'gray70', lc rgb 'gray90'
set mxtics
set mytics
# Make yrange > ytics > function to get padding.
set yrange [-1.5:1.5]
set ytics ("" -1.5, -1.25 1, -1.0, -0.75 1, -0.5, -0.25 1, 0.0, 0.25 1, 0.5, 0.75 1, 1.0, 1.25 1, "" -1.5)
set xtics 0,1,5
set xrange [0:5]
set xtics
set mxtics
set mytics
set format x ""
set grid xtics ytics mxtics mytics ls -1 ls -1 lc rgb 'gray60', lc rgb '#C0E5E5E5''
set multiplot layout (n+1),1 #font ",14" title 'Input And Output Voltages Of Differential Amplifier'
### First plot
# change only plot command here
currentplot = 1
set tmargin at screen top(currentplot,n,h,t,b)
set bmargin at screen bot(currentplot,n,h,t,b)
unset key
unset xlabel
set title 'Input (Bottom) And Output (Top) Voltages Of The Differential Amplifier'
set ylabel 'Voltage [V]'
plot 'DifferentialAmplfier.dat' using (1000*$1):2 with lines lw 20 lc rgb 'dark-magenta'
### Last plot
# change only plot command here
currentplot = currentplot + 1
set tmargin at screen top(currentplot,n,h,t,b)
set bmargin at screen bot(currentplot,n,h,t,b)
set format x
unset title
set xlabel 'Time [ms]'
set ylabel 'Voltage [mV]'
plot 'DifferentialAmplfier.dat' using (1000*$1):(1000*$3) with lines lw 10 lc rgb 'navy'
unset multiplot
set term x11
有问题/狡猾的修复...
【问题讨论】:
-
你可以通过增加边框来作弊,但我认为你不希望这样......
-
是的,我也想过,但这确实有点糟糕,我最终得到了巨大的边界。我也想过在它上面画一个白色的矩形,但这看起来很荒谬。您是否知道是否至少有一种方法可以将曲线带到最前面的图层以便越过边界?
-
实际上已经想出了如何做到这一点...
set border back -
问题是,gnuplot 在核心代码中进行了裁剪,它只能尊重坐标,而不能尊重线条的形状。这将需要对代码进行大量更改。我仍然很好奇对您的功能请求的反馈。
-
用户有时也会做出奇怪的事情
;)。确实需要一个逗号:逗号之前的都是主轴,逗号后面的都是短轴。而ls -1没有意义,因为linestyle是用户定义的样式,必须有一个数字> 0。你的意思是lt -1,在你的情况下,gnuplot 会退回到它。所以你的网格选项是set grid mxtics mytics xtics ytics lt -1 lc rgb 'gray70', lt -1 lc rgb 'gray90'。
标签: gnuplot