【问题标题】:GNUPLOT - Can't display values over the barGNUPLOT - 无法在栏上显示值
【发布时间】:2016-11-07 16:08:20
【问题描述】:

我正在尝试用这个文件'.dat'制作简单的直方图

Moment "Energy consumed (MWh)"
"Apr-16" 2011.4
"May-16" 1869.6
"Jun-16" 1899.0
"Jul-16" 1659.0
"Aug-16" 1740.6
"Sep-16" 1670.0

为此,我编写了以下脚本

  #!/usr/bin/gnuplot
  set term postscript
  set terminal pngcairo nocrop enhanced size 700,700 font "arial,18"
  set termoption dash
  set output out
  set boxwidth 0.5 absolute
  set border 0
  set style fill   solid 1.00 border lt -1
  set key off
  set style histogram clustered gap 1 title textcolor lt -1
  set datafile missing '-'
  set style data histograms
  set xtics border in scale 0,0 nomirror autojustify
  set xtics  norangelimit
  set xtics ()
  unset ytics
  set title titulo
  set yrange [0.0000 : limite] noreverse nowriteback

  show style line
  set style line 1 lt 1 lc rgb color lw 1

  ## Last datafile plotted: "immigration.dat"
  plot fuente using (column(0)):2:xtic(1) title titulo ls 1 with boxes, '' using 0:2:2 with labels

在这种情况下,out 是输出文件名,titulo 是出现在图像输出顶部的标签,limite 是我在 y 轴上用作最大值的值,@987654328 @ 是源文件名。

结果是这样的

我正在尝试以一些偏移量在条形上方显示值,因为我需要条形上方而不是条形内部的值。我需要单独尝试使用如下代码:

plot fuente using (column(0)):2:xtic(1) title titulo ls 1 with boxes, '' using 0:($2 + 0.5):2 with labels

因为我看到很多网站都在使用$2 + 0.5,但这对我不起作用。

我该怎么办?请帮助我,我完全迷路了。提前致谢。

【问题讨论】:

    标签: gnuplot histogram


    【解决方案1】:

    offset 参数用于with labels 绘图样式。有了这个,您可以添加您指定的垂直偏移量,例如以charactergraph 为单位:

    plot fuente using 0:2:xtic(1) with boxes, '' using 0:2:2 with labels offset 0, char 1
    

    旁注:将0.5 的常量值添加到 y 值(如 $2 + 0.5)对您不起作用,因为 0.5 以 y 轴为单位,与你的年龄。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-05
    • 2021-07-14
    • 2011-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多