简体   繁体   English

gnuplot:添加“ set xrange”时图消失

[英]gnuplot: plot disappears when adding “set xrange”

I've got a strange problem using "set xrange" with a simple code and I don't get it. 我用一个简单的代码使用“ set xrange”遇到了一个奇怪的问题,但我不明白。 I have the code: 我有代码:

set style data histograms    
set style histogram clustered gap 1    
set style fill solid 1.0     
set boxwidth 0.9    
set auto x    
set xtic rotate by -70 scale 1     
set yrange [0:32]    
set ylabel 'percentage [%]'    
set xlabel 'Year'    
set key top left

plot '../ölkj.txt' using 3 title 'ölkj', 'asdf.txt' u 2 title 'asdf'

Everything is fine. 一切顺利。 But when I add 但是当我添加

set xrange[1997:2014]

the plot disappears, just the axes, their label and the legend remains. 情节消失了,只剩下了轴,它们的标签和图例。

The data is in the following format: 数据格式如下:

2012    14,81   20
2013    15,11   18,18
2014    15,83   20

Any ideas? 有任何想法吗?

I had a similar problem just now using time data: 我刚才使用时间数据遇到了类似的问题:

I used 我用了

set timefmt "%s"
set ydata time
set yrange [0:600]

and my plot disappeared. 我的情节消失了

Replacing set yrange [0:600] with set yrange ["0":"600"] made it appear again. set yrange ["0":"600"]替换set yrange [0:600]使它再次出现。

This might be caused by gnuplot not parsing the yrange arguments when its not enclosed in " and using a different internal representation for timestamps. 这可能是由于gnuplot未将yrange参数解析(如果未将yrange参数括在"并且对时间戳使用了不同的内部表示造成的。

I could observe this by looking at the mouse-coordinates on the empty plot. 我可以通过查看空图上的鼠标坐标来观察到这一点。 Pressing "Apply autoscale" made gnuplot show my plot. 按下“应用自动缩放”使gnuplot显示我的图。 The mouse-coordinates then looked totally different. 鼠标坐标看起来完全不同。

I think what you are trying to achieve by set xrange is to get the year labels on your x-axis. 我认为您要通过set xrange来实现的目标是在x轴上获得年份标签。 You can do that by just altering your plot command to: 您只需将plot命令更改为:

plot '../ölkj.txt' using 3:xtic(1) title 'ölkj', 'asdf.txt' u 2:xtic(1) title 'asdf'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM