重复y轴刻度标签 [英] Repeating y-axis tick labels

查看:73
本文介绍了重复y轴刻度标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用gnuplot(版本4.4)时发现了这种奇怪的行为,当使用 set format y%10.0f" 命令并且y范围相对较低时,它会重复相同的y轴刻度标签. .如果将其设置为%10.5f",则不会重复数字,但是在我的情况下,"0.5"舍入是不合逻辑的.因此,我正在寻找对以下脚本进行最少更改的解决方案,感谢您的帮助!

I found this strange behaviour when using gnuplot (ver 4.4), it repeats the same y-axis ticks labels when set format y "%10.0f" command is used and y range is relatively low. If I set it up to "%10.5f" the numbers don't repeat but the "0.5" rounding isn't logical in my case. So I'm looking for a solution with minimal changes to the following script, any help appreciated!

具有重复的y轴刻度标签的示例:

Example with repeating y-axis ticks labels:

数据:

0.5 -
1   3.000
2   4.000
3   4.000
4   2.000
5   1.000

脚本:

set encoding cp1250
set datafile separator "\t"
set datafile missing "-"

set terminal png font "arial" small size 1090,282 xffffff x000000 x404040 x00aa66     xdd3300
set output "output.png"

set key off

set grid
set boxwidth 0.9 relative
set style data histograms
set style fill solid 0.6 border -1
set decimalsign ","
set format y "%10.0f"
set xtics ('28.02.2011-06.03.2011' 1,'07.03.2011-13.03.2011' 2,'14.03.2011-20.03.2011'     3,'21.03.2011-27.03.2011' 4,'28.03.2011-03.04.2011' 5)
set ylabel 'Label'
set xrange [0.5:5.5]
plot "data.dat" using 2

推荐答案

重复y tic条目是由于您格式化y tic的显示格式不带任何小数位.因此,3,5会四舍五入为4,依此类推.有一些解决方案可以避免这种情况.

The repetition of y tic entries is due to the fact that you format the y tics to be displayed without any decimal places. Therefore a 3,5 is rounded towards a 4 and and so forth. There are a few solutions that would circumvent that.

  1. 允许显示小数位:set format y "%.1f"
  2. 尝试不熟悉set ytics autofreq.例如
    set ytics autofreq 1将完成您尝试在脚本中实现的相同目的,但无需重复.
  1. Allow decimal places to be displayed: set format y "%.1f"
  2. Try too fool around with set ytics autofreq. For instance
    set ytics autofreq 1 would accomplish the same thing you try to achieve in your script but without the repetition.

希望有帮助...
切里奥
卧龙

Hope that helped...
Cherio
Woltan

这篇关于重复y轴刻度标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆