未定义的变量:GPVAL_DATA_Y_MIN(Gnuplot) [英] undefined variable: GPVAL_DATA_Y_MIN (Gnuplot)
问题描述
基于此帖子(我正在使用gnuplot gnuplot 4.6补丁程序级别1):
Based on this post (I am using gnuplot gnuplot 4.6 patchlevel 1):
我正在尝试在.pg脚本中使用set yr [GPVAL_DATA_Y_MIN:GPVAL_DATA_Y_MAX]
来绘制来自此.dat文件的数据:
I am trying to use set yr [GPVAL_DATA_Y_MIN:GPVAL_DATA_Y_MAX]
in my .pg script that plots data from this .dat file:
100 2
200 4
300 9
但是我得到:
undefined variable: GPVAL_DATA_Y_MIN
这是我的脚本:
set terminal png
set output 'img.png'
set xlabel 'x-label'
set ylabel 'y-label'
set boxwidth 0.5
set style fill solid
set yrange [GPVAL_DATA_Y_MIN:GPVAL_DATA_Y_MAX]
plot 'sample.dat' with boxes title ""
有什么想法吗?
推荐答案
gnuplot定义的变量仅在plot
命令之后可用(在链接到的问题中,将使用replot
重新绘制).
The gnuplot-defined variables are available only after a plot
command (In the question you linked to, a replot
is used to plot again).
基本上,您有不同的选择:
Basically you have different options:
-
首先绘制到端子
unknown
,然后更改为真实端子,设置范围(现在变量可用),然后replot
:
First plot to terminal
unknown
, and then change to the real terminal, set the range (now the variables are available), andreplot
:
set xlabel 'x-label'
set ylabel 'y-label'
set boxwidth 0.5 relative
set style fill solid
set terminal unknown
plot 'sample.dat' with boxes title ""
set terminal pngcairo
set output 'img.png'
set yrange [GPVAL_DATA_Y_MIN:GPVAL_DATA_Y_MAX]
replot
请注意,我使用的pngcairo
终端比png
终端提供了更好的结果.我用了set boxwidth 0.5 relative
.
Note, that I used the pngcairo
terminal, which gives much better results, than the png
terminal. And I used set boxwidth 0.5 relative
.
使用set autoscale
固定范围,而不是设置显式的yrange
.您可以使用set offset
根据自动缩放的值指定边距:
Use set autoscale
to fix the ranges instead of setting an explicit yrange
. You can use set offset
to specify a margin based on the autoscaled values:
set autoscale yfix
# set offset 0,0,0.5,0.5
plot 'sample.dat' with boxes title ''
使用stats
命令提取最小值和最大值:
Use the stats
command to extract the minimum and maximum values:
stats 'sample.dat' using 1:2
set yrange[STATS_min_y:STATS_max_y]
plot 'sample.dat' with boxes title ''
这篇关于未定义的变量:GPVAL_DATA_Y_MIN(Gnuplot)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!