3

有没有办法使图形的 x/y tic-labels 的格式取决于 tic 的值?我正在设想格式的声明

set format y ( ( ( <arg> > 1e-3 ) && ( <arg> < 1e2 ) ) ?  "%2.1f" : "10^{%T}" )

这样对数比例图将表示为

10^{-4}, 10^{-3}, 0.01, 0.1, 1, 10, 10^{2}

等等,为接近 1 的数字提供更自然的表示。

我知道这可以通过明确声明格式来完成,即

set xtics ( "10^{-3}" 1e-3, "0.01" 0.01, "0.1" 0.1, "1" 1, "10" 10, "10^{2)" 1e2 )

但我想避免如此具体,因为每次图表范围发生变化时,这组标签都会发生变化。我希望这个问题的答案是“不”,但这是希望。

4

1 回答 1

5

嗯……这取决于你想要制作这个情节的努力程度。这是一个执行您想要的示例的示例。以自动化方式制作的情节有点困难,(您需要调整标题的边距等)但如果您只需要一个漂亮的演示文稿或论文的情节并且有时间花时间让它看起来像您想要的那样,这应该可以正常工作。

set termoption enhanced

#for this to work, we need to set ranges explicitly :-(
set xrange [-10:10]
set yrange [1e-4:exp(10)]

#Yippee!!! logscale plots :-)
set logscale y

#We'll make 3 plots.  The first plot is of the data and a piece of the y range tics
# the next two plots have no data, they only add another piece of the range tics.
set multiplot

#for this to work, we have to guarantee that all the plots line up exactly
set lmargin at screen 0.1
set bmargin at screen 0.1
set rmargin at screen 0.9
set tmargin at screen 0.9

set ytics 1e-2,10,90 format "%g"  #center of the range, normal tics.
plot exp(x)+exp(-x)               #looks like a V in logscale.  Neat.
unset xtics                       #already did this once.  don't need to put it on again.
unset border                      #already did this once too...
set ytics 100,10 format "10^{%L}" #Next plot, top end of the tics
plot NaN notitle                  #plots nothing.  Only works if range is set explicitly.
set ytics 1e-5,10,9e-3            #next plot, low end of the tics

#Any additional labels, objects, arrows, the title etc. should go here.  
#Otherwise you'll need to unset them like we did with the xtics and border 
#to prevent them from being plotted twice 
#(objects which are plotted twice sometimes look a little bit darker than they should).

plot NaN notitle
unset multiplot                   #and we're done.
于 2012-07-12T02:39:56.180 回答