GNUPLOT-无法在条形图上显示值 [英] GNUPLOT - Can't display values over the bar

查看:129
本文介绍了GNUPLOT-无法在条形图上显示值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此文件'.dat'创建简单的直方图

I'm trying make simple histogram with this file '.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

为此,我编写了以下脚本

For this purpose I have written the following script

  #!/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-axi上用作最大值的值,而是源文件名.

In this case out is the output filename, titulo is the label that appears on the top of the image output, limite is the value that I use as biggest value on y-axi, and fuente is the source filename.

结果是这个

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

I am trying display the values over the bar with some offset because I need the values over the bars and not inside the bars. I would need separate I am trying with code like:

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,但这对我来说不起作用.

because I have seen many sites where they get it doing $2 + 0.5 but this it doesn't work for me.

我该怎么办?请帮助我,我完全迷路了.预先感谢.

What should I do? Please help me I am completly lost. Thanks in advance.

推荐答案

对于with labels绘图样式,请使用offset参数.使用此功能,您可以添加一个垂直偏移量,例如您可以指定以charactergraph单位:

Use the offset parameter for the with labels plotting styles. With this you can add a vertical offset which you specify e.g. in character or graph units:

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轴为单位,与你的橘子.

Sidenote: Adding the constant value of 0.5 to the y-value (like $2 + 0.5) doesn't work for you, because the 0.5 is in units of the y-axis, and very small compared to your yrange.

这篇关于GNUPLOT-无法在条形图上显示值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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