1

我在 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

有问题/狡猾的修复...

GraphDodgyFix

4

1 回答 1

2

有一种方法可以做到这一点,但它很麻烦。您将使用多图,绘制您的数据,然后通过明智地使用graphscreen坐标系在您的绘图周围绘制白色矩形,然后重新绘制一个空绘图以重新绘制边界(因为矩形将覆盖您的标签和一半的边界线厚度)。这是一个 MWE:

#!/usr/bin/gnuplot -persist

reset
f(x) = sin(x)

xl=0; xh=20; yl=-1; yh=1;
set xrange [xl:xh]
set yrange [yl:yh]

set multiplot

plot f(x) not w l lt 3 lw 12

## overdraw borders on left, right, top, bottom
set object 1 rectangle from screen 0, screen 0 to graph 0, screen 1 behind \
  fillstyle solid noborder
set object 2 rectangle from graph 1, screen 0 to screen 1, screen 1 behind \
  fillstyle solid noborder
set object 3 rectangle from screen 0, graph 1 to screen 1, screen 1 behind \
  fillstyle solid noborder
set object 4 rectangle from screen 0, screen 0 to screen 1, graph 0 behind \
  fillstyle solid noborder

plot NaN not

unset multiplot

边缘过度绘制示例

于 2013-09-19T19:47:49.780 回答