Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gnuplot 具有不同x轴标签的单个直方图多个y轴_Gnuplot_Histogram - Fatal编程技术网

Gnuplot 具有不同x轴标签的单个直方图多个y轴

Gnuplot 具有不同x轴标签的单个直方图多个y轴,gnuplot,histogram,Gnuplot,Histogram,我的test.dat文件看起来像 # Experiment No. Total U_Na-Z (millimoles/g of zeolite) Total Na_Na-Z in melt (mmoles/g zeolite) Total U_Li-Z (millimoles/g of zeolite) Total Na_Li-Z in melt (mmoles/g zeolite) Experiment No. Total U loading (mmoles/g zeoli

我的test.dat文件看起来像

# Experiment No.  Total U_Na-Z (millimoles/g of zeolite) Total Na_Na-Z in melt (mmoles/g zeolite)         Total U_Li-Z (millimoles/g of zeolite) Total Na_Li-Z in melt (mmoles/g zeolite)
Experiment No.  Total U loading (mmoles/g zeolite)   Total Na in melt (mmoles/g of zeolite)           Total U loading (mmoles/g zeolite)   Total Na in melt (mmoles/g of zeolite) 
1                0.074798319                          4.60                                              0.061795848                          1.38
2                0.148512605                          3.73                                              0.122910867                          1.72
3                0.223310924                          4.02                                              0.216806723                          1.46
4                0.287268908                          5.26                                              0.275399753                          1.60               
我想用两个y轴(第2列为y,第3列为y2)和第1列x轴绘制一个柱状图,在同一柱状图中,第4列为y,第5列为y2必须与第1列绘制,当然颜色不同。脚本如下所示:gnuplot中的newhistogram脚本已相应修改

set terminal postscript eps enhanced colour font 'Times-Roman,12' size 5in,4in  
set output "Histogram1.eps"
#------------------------------------------------------------------------------
set style line 1 lt 2 lw 1 lc rgb "#000FF"
set style line 2 lt 3 lw 1 lc rgb "#228B22"
set style line 3 lt 4 lw 1 lc rgb "#FF4500"
set style line 4 lt 5 lw 1 lc rgb "#8B0000"
set style line 5 lt 6 lw 1 lc rgb "dark-magenta"
#------------------------------------------------------------------------------
set xtics out scale 1.5 
set ytics out scale 1.5
set y2tics out scale 1.5 
set ytics nomirror
set yrange [0:0.50]
set y2range [0:6] 
set key off
set tics font ", 14"
set xlabel "Experiment No." font ",16"
set ylabel "U loading in zeolite (mmoles/g zeolite)" font ",16"
set y2label "Na in melt (mmoles/g zeolite)" font ",16"
set key autotitle columnheader
set key inside left horizontal
set style fill solid 1.00 noborder
set style histogram clustered gap 1 title textcolor lt -1
# ----------------------------------------
set rmargin screen 0.9
set lmargin screen 0.1
set bmargin screen 0.1
# ----------------------------------------
现在,plot命令作为

plot \
newhistogram "Sodium Zeolite", \
'test.dat' using 2:xtic(1) ls 1 ti col axis x1y1, '' 3:xticlabels(1) ls 2 ti col axis x1y2, \
newhistogram "Lithium Zeolite", \
'' using 4:xtic(1) ls 3 ti col axis x1y1, '' 5:xticlabels(1) ls 4 ti col axis x1y2 
在x轴上,对于前四个数据,必须显示钠沸石,对于嵌套四个数据,必须显示锂沸石。但它似乎不起作用。任何建议都会有所帮助

谢谢,

几个小问题:

您需要告诉程序使用直方图打印样式。最好的方法是在plot命令之前添加一行:

set style data histogram
plot \
  newhistogram "Sodium Zeolite", \
  'test.dat' using 2:xtic(1) ls 1 ti col axes x1y1, \
  '' using 3 ls 2 ti col axes x1y2, \
  newhistogram "Lithium Zeolite", \
  '' using 4:xtic(1) ls 3 ti col axes x1y1, \
  '' using 5 ls 4 ti col axes x1y2
设置样式数据直方图

关键字是axis,而不是axis

using关键字必须出现在每个plot子句中

每个绘图不必多次使用xticlabels1命令,尽管这也不会造成任何伤害,但标签将在同一位置打印两次

这将提供一个修改后的plot命令:

set style data histogram
plot \
  newhistogram "Sodium Zeolite", \
  'test.dat' using 2:xtic(1) ls 1 ti col axes x1y1, \
  '' using 3 ls 2 ti col axes x1y2, \
  newhistogram "Lithium Zeolite", \
  '' using 4:xtic(1) ls 3 ti col axes x1y1, \
  '' using 5 ls 4 ti col axes x1y2
输出如图所示 几个小问题:

您需要告诉程序使用直方图打印样式。最好的方法是在plot命令之前添加一行:

set style data histogram
plot \
  newhistogram "Sodium Zeolite", \
  'test.dat' using 2:xtic(1) ls 1 ti col axes x1y1, \
  '' using 3 ls 2 ti col axes x1y2, \
  newhistogram "Lithium Zeolite", \
  '' using 4:xtic(1) ls 3 ti col axes x1y1, \
  '' using 5 ls 4 ti col axes x1y2
设置样式数据直方图

关键字是axis,而不是axis

using关键字必须出现在每个plot子句中

每个绘图不必多次使用xticlabels1命令,尽管这也不会造成任何伤害,但标签将在同一位置打印两次

这将提供一个修改后的plot命令:

set style data histogram
plot \
  newhistogram "Sodium Zeolite", \
  'test.dat' using 2:xtic(1) ls 1 ti col axes x1y1, \
  '' using 3 ls 2 ti col axes x1y2, \
  newhistogram "Lithium Zeolite", \
  '' using 4:xtic(1) ls 3 ti col axes x1y1, \
  '' using 5 ls 4 ti col axes x1y2
输出如图所示