Gnuplot将Xtics放置在小节之间 [英] Gnuplot put xtics between bars

查看:164
本文介绍了Gnuplot将Xtics放置在小节之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够放置tic标记,以便它们位于图形中的条形图之间. 这样,可以看出在0和14之间有2个点,在15和30之间有2个点,依此类推,而不是位于条形图下方居中的抽签.有什么方法可以根据盒子的宽度自动执行此操作吗? 这是我当前的脚本尝试:

I need to be able to position the tic marks so that they are between the bars in the graph. That way it can be read that there were 2 points between 0 and 14, 0 between 15 and 30, and so on, instead of the tics centered underneath the bars. Is there any way to automatically do that based on the box width? Here is my current script attempt:

set xtics out nomirror
set ytics out nomirror
set tic scale 0
set style fill solid 1.00 border 0
set offset graph 0.1, 0.05, 0.1, 0.0
set boxwidth 15 *.9
set xtics offset -(15 *.9)/2
set term png
set output "graph.png"
plot 'data.dat' using 1:2:xtic(1) with boxes

这是.dat:

0       2
15      0
30      0
45      0
60      1
75      1
90      33

编辑 似乎基于boxwidth,以下内容始终有效:

EDIT It appears that the following works consistently, based on the boxwidth:

set bwidth=15*.9
set boxwidth bwidth
set xtics out nomirror offset -bwidth/2 left

也许还有更好的方法.

推荐答案

使用您的解决方案,您只需移动tic标签.我也会改变抽动.

With your solution you only shift the tic labels. I would also shift the tics.

这是我的解决方案:

set tics out nomirror
set style fill solid 1.00 noborder
set autoscale fix
set offset 5,5,5,0

# extract the first and second x-values
stats 'data.dat' using 1 every ::::1 nooutput
start = STATS_min
width = STATS_max - STATS_min

set boxwidth width *.9
set xtics start, width

set term pngcairo
set output "graph.png"

plot 'data.dat' using ($1+width/2.0):2 with boxes

自动提取第一个和第二个数据值(需要版本> = 4.6.0).这些值用于

The first and second data values are extracted automatically (requires version >= 4.6.0). These values are used to

  1. 设置框宽

  1. Set the boxwidth

设置xtics(起始值和增量)

Set the xtics (start value and increment)

将数据点移位x值增量的一半.

Shift the data points by half of the x-value increment.

例如参见 Gnuplot:如何从数据文件中加载和显示单个数值,这是使用stats命令提取数据的另一个示例.除了使用stats加载数据外,您当然也可以使用

See e.g. Gnuplot: How to load and display single numeric value from data file for another example for extracting data with the stats command. Instead of loading the data with stats you could of course also use

start = 0
width = 15

4.6.3的结果是:

The result with 4.6.3 is:

这篇关于Gnuplot将Xtics放置在小节之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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