3

目盛りの値に依存するグラフの x/y 目盛りラベルの形式を作成する方法はありますか? 私はフォーマットのステートメントを想定しています

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 に答える