Gnuplot:多点绘图,只是曲线,没有轴或标题等
我使用以下脚本生成了一个绘图,结果如下图所示。很难看出,但在Gnuplot:多点绘图,只是曲线,没有轴或标题等,gnuplot,Gnuplot,我使用以下脚本生成了一个绘图,结果如下图所示。很难看出,但在多点打印中,每次调用绘图函数时,都会反复绘制xlabel、ylabel、title和tic编号。在我的想法中,我如何避免这种情况,而只绘制图形而不做任何其他事情?如果我取消设置标题、tics等,然后进行绘图,则图形不会在与帧相同的区域进行绘图,并在左y轴所在的位置进行平移 #set datafile separator ' ' set samples 1000 set term tikz size 17cm,10cm dashed s
多点打印
中,每次调用绘图
函数时,都会反复绘制xlabel、ylabel、title和tic编号。在我的想法中,我如何避免这种情况,而只绘制图形而不做任何其他事情?如果我取消设置标题、tics等,然后进行绘图,则图形不会在与帧相同的区域进行绘图,并在左y轴所在的位置进行平移
#set datafile separator ' '
set samples 1000
set term tikz size 17cm,10cm dashed
set out 'MosfetClassAbPower.tex'
unset key
set border lw 2
set style fill transparent solid 0.5 noborder
set title 'MOSFET $\mathrm{I_D}$ Vs Time'
set ylabel 'Drain Current [$\mu$A]'
set xlabel 'Time [ms]'
set xrange [0:4]
set xtics 0,0.5,4
set mxtics 4
set yrange [-50:450]
set mytics 4
set rmargin 5
set label 1 '\SI{60}{\micro\ampere}' at 4.02,60
set multiplot
set grid mxtics mytics lt -1 lc rgb 'gray90'
plot NaN notitle
unset grid
set grid xtics ytics lt -1 lc rgb 'gray70'
plot NaN notitle
unset grid
plot NaN notitle
Id(x) = 347*sin(2*3.14*x) + 60
ID(x) = Id(x) >= 0 ? Id(x) : 0
plot ID(x) w filledcurves above y1=0 lc rgb 'light-blue',\
60 w lines lt 2 lw 3 lc rgb 'gray60',\
ID(x) w lines lt 1 lw 5 lc rgb 'navy'
plot NaN notitle
unset multiplot
set out
我试图防止曲线突出框架。
编辑:
不可能为所有打印元素设置不同的图层并任意堆叠它们。您必须对各种元素使用
set
和unset
0
(这适用于主要tic,但不适用于次要tic,我使用0.001
)标签
,对象
,箭头
,tics标签等)。不要unset tics
,因为我们希望最后绘制它们,所以只需使用set format x'
绘制tics,而不是它们的标签reset
set term tikz size 17cm,10cm dashed standalone header '\usepackage{siunitx}'
set out 'MosfetClassAbPower.tex'
TSCALE = 1.0
# set terminal pdfcairo
# TSCALE = 20.0 # use this value for e.g. pdfcairo or cairolatex
set style fill transparent solid 0.5 noborder
set title 'MOSFET $I_D$ Vs Time'
set ylabel 'Drain Current (in \si{\uA})'
set xlabel 'Time (in \si{\ms})'
set xrange [0:4]
set xtics 0,0.5,4
set mxtics 4
set yrange [-50:450]
set mytics 4
set rmargin 5
set label 1 '\SI{60}{\uA}' at graph 1.01, first 60
unset key
set samples 1000
set multiplot
unset border
set tics scale 0,0.001
set grid mxtics mytics lt -1 lc rgb 'gray90'
plot NaN
unset grid
# keep the current margins for all following plots
set lmargin at screen TSCALE*GPVAL_TERM_XMIN/(1.0*GPVAL_TERM_XSIZE)
set rmargin at screen TSCALE*GPVAL_TERM_XMAX/(1.0*GPVAL_TERM_XSIZE)
set tmargin at screen TSCALE*GPVAL_TERM_YMAX/(1.0*GPVAL_TERM_YSIZE)
set bmargin at screen TSCALE*GPVAL_TERM_YMIN/(1.0*GPVAL_TERM_YSIZE)
# unset almost everything
unset border
unset label
unset xlabel
unset ylabel
set format x ''
set format y ''
unset title
set grid xtics ytics lt -1 lc rgb 'gray70'
plot NaN
unset grid
set tics scale 1,0.5 front
set border
set border lw 2
Id(x) = 347*sin(2*3.14*x) + 60
ID(x) = Id(x) >= 0 ? Id(x) : 0
plot ID(x) w filledcurves above y1=0 lc rgb 'light-blue',\
60 w lines lt 2 lw 3 lc rgb 'gray60',\
ID(x) w lines lt 1 lw 5 lc rgb 'navy'
unset multiplot
set out
graph
坐标来设置标签。和一些标签文本的调整
编辑:
Cairolatex或EPS乳胶
上述过程适用于同时处理文本和图形的任何终端,但不适用于cairolatex
和epsletex
等终端,它们在multiplot
模式下只知道两个文本层:
front
层,包含放置有front
关键字的所有文本plot
命令的所有图形元素(也处于multiplot
模式)back
层,包含放置有back
关键字的所有文本xlabel
放在前面,则可能会出现问题。下面是一个同样适用于cairolatex
的示例:
reset
set terminal cairolatex pdf dashed color standalone header "\\usepackage{siunitx}" size 17cm,10cm
set output 'MosfetClassAbPowerFixed.tex'
TITLE = 'MOSFET $I_D$ Vs Time'
YLABEL = 'Drain Current (in \si{\uA})'
XLABEL = 'Time (in \si{\ms})'
set style fill transparent solid 0.5 noborder
set xrange [0:4]
set xtics 0,0.5,4
set mxtics 4
set yrange [-50:450]
set mytics 4
RMARGIN=0.92
LMARGIN=0.1
set rmargin at screen RMARGIN
set lmargin at screen LMARGIN
set tmargin at screen 0.91
set bmargin at screen 0.11
unset key
set samples 1000
set multiplot
# first plot the minor grid lines
unset border
set tics scale 0,0.001 format ''
set grid mxtics mytics lt -1 lc rgb 'gray90'
plot NaN
# now plot the major grid lines
unset grid
set grid xtics ytics lt -1 lc rgb 'gray70'
plot NaN
unset grid
# plot the actual curve
# overdraw borders on left and right
set object rectangle from graph -0.005, graph 0 to screen LMARGIN, graph 1 front \
fillstyle solid noborder
set object rectangle from screen RMARGIN, graph 0 to graph 1.005, graph 1 front \
fillstyle solid noborder
Id(x) = 347*sin(2*3.14*x) + 60
ID(x) = Id(x) >= 0 ? Id(x) : 0
plot ID(x) w filledcurves above y1=0 lc rgb 'light-blue',\
60 w lines lt 2 lw 3 lc rgb 'gray60',\
ID(x) w lines lt 1 lw 5 lc rgb 'navy'
unset object
# plot all tics and labels
LABEL = '\SI{60}{\uA}'
set label 1 LABEL at graph 1.01, first 60 front
set title TITLE
set ylabel YLABEL
set xlabel XLABEL
set tics scale 1,0.5 format
set border
set border lw 2
plot NaN
unset multiplot
set out
因为只有三层,所以我在绘图边界和tic标签之间放置了薄的白色矩形。若要在打印区域外绘制对象,需要在屏幕
坐标中至少使用一个坐标值,否则将对其进行剪裁
与第一个示例相反,我对整个绘图使用了固定的边距,这是我更喜欢的
这使得:
我做了
multiplot
,这样主要线条就可以画在次要线条的上面,而不是相反。我的问题实际上是关于如何使用multiplot
并使其工作multiplot
允许我按所需顺序绘制东西。我知道你是怎么做的,但是它没有正确地排列网格线。有没有一种方法可以在不绘制所有标签的情况下(也不必全部取消设置以避免绘制所有标签)在multiplot中绘制曲线?@user968243查看编辑后的答案。要使不同层上的所有元素按自定义顺序排列,需要进行一些修改。这是不可能的开箱即用,以自定义顺序排列所有绘图元素。好的,太好了!谢谢我想你忘了取消设置标题
在之后#取消设置几乎所有内容
。另外,我注意到您的解决方案似乎与其他终端不兼容,即,pdfcairo
和cairolatex
。由于某种原因,该图形在左下角绘制。你知道如何使它与这些终端兼容吗?再次非常感谢@user968243一些终端通过过采样因子缩放GPVAL\u TERM\u*MIN
和GPVAL\u TERM\u*MAX
值,但不缩放GPVAL\u TERM\u*SIZE
值。此系数不能作为GPVAL.*
变量访问。可以对其进行检查,但会变得很长,请参见“我的编辑到”。在您的情况下(pdfcairo
或cairolatex
),您需要按系数20
缩放所有边距,请参见我的编辑。@user968243cairolatex
和epsletex
终端的工作方式稍有不同。这一点很重要,在分层时,请参见我的编辑。
reset
set terminal cairolatex pdf dashed color standalone header "\\usepackage{siunitx}" size 17cm,10cm
set output 'MosfetClassAbPowerFixed.tex'
TITLE = 'MOSFET $I_D$ Vs Time'
YLABEL = 'Drain Current (in \si{\uA})'
XLABEL = 'Time (in \si{\ms})'
set style fill transparent solid 0.5 noborder
set xrange [0:4]
set xtics 0,0.5,4
set mxtics 4
set yrange [-50:450]
set mytics 4
RMARGIN=0.92
LMARGIN=0.1
set rmargin at screen RMARGIN
set lmargin at screen LMARGIN
set tmargin at screen 0.91
set bmargin at screen 0.11
unset key
set samples 1000
set multiplot
# first plot the minor grid lines
unset border
set tics scale 0,0.001 format ''
set grid mxtics mytics lt -1 lc rgb 'gray90'
plot NaN
# now plot the major grid lines
unset grid
set grid xtics ytics lt -1 lc rgb 'gray70'
plot NaN
unset grid
# plot the actual curve
# overdraw borders on left and right
set object rectangle from graph -0.005, graph 0 to screen LMARGIN, graph 1 front \
fillstyle solid noborder
set object rectangle from screen RMARGIN, graph 0 to graph 1.005, graph 1 front \
fillstyle solid noborder
Id(x) = 347*sin(2*3.14*x) + 60
ID(x) = Id(x) >= 0 ? Id(x) : 0
plot ID(x) w filledcurves above y1=0 lc rgb 'light-blue',\
60 w lines lt 2 lw 3 lc rgb 'gray60',\
ID(x) w lines lt 1 lw 5 lc rgb 'navy'
unset object
# plot all tics and labels
LABEL = '\SI{60}{\uA}'
set label 1 LABEL at graph 1.01, first 60 front
set title TITLE
set ylabel YLABEL
set xlabel XLABEL
set tics scale 1,0.5 format
set border
set border lw 2
plot NaN
unset multiplot
set out