首页 > 解决方案 > 绘制与 gnuplot 对齐的多个轴

问题描述

我正在尝试在左侧绘制时间序列,在右侧绘制直方图。我有 10000 个样本。文件 ts.dat 和 hist.dat 包含要以正确形式绘制的点。如何绘制对齐的两个轴?使用下面的代码,gnuplot 对齐画布,并且由于 x 标签的长度不同,因此轴 y 长度也不同。

set term pngcairo font "Times New Roman, 8" size 640, 240
set out 'mp.png'
set multiplot
set tics out
set tics scale 0.5
unset key
set size .66, 1
set yrange[-6:6]
set xtics rotate by 45 right
set xlabel "Iteration no."
set ylabel "USD"
plot 'ts.dat' with lines
set origin .66, 0
set size .33, 1
set yrange [-6:6]
set format y ""
set style fill transparent solid 0.3
set xlabel "No. of occurences"
unset ylabel
plot 'hist.dat' using 2:1 with filledcurves
unset multiplot

在此处输入图像描述

标签: time-seriesgnuplot

解决方案


检查help margins

如果您手动设置固定的底部边距,例如set bmargin 3set bmargin at screen 0.1,则底部 x 轴应在两个图中对齐。


推荐阅读