Gnuplot背景与多色

时间:2014-08-15 08:10:55

标签: background gnuplot

我在使用多色时遇到了一些困难。我正在绘制风向并且背景图像正在通过第二个(叠加)数据图重新调整。这是我的代码:

set terminal png size 1000,750
set size 1,1
#ratio of canvas used (set with set terminal above)
set multiplot
set xrange [0:1000]  ##size of png terminal 1000,750
set yrange [0:750]
# background picture's size is 1000x750 pixels,         
# use xrange and yrange of these values
set grid
#unset tics
#unset border
#set lmargin at screen 0.175
#set rmargin at screen 0.9
set bmargin at screen 0.2
#set tmargin at screen 0.9
#Plot the background image
plot "plot_backgrnd2.png" binary filetype=png w rgbimage notitle 

#Plot the wind data on top of the background image

set terminal png size 1000,750
set output "winddir.png"

#set style line 1 lw 2 lc rgb "red"
set style line 2 lw 2 lc rgb "blue"
#set style line 4 lw 1 lc rgb "sea-green"
set style increment user
# out draws the tic marks on the outside of the border; otherwise they'd be
# obscured by the boxes.
#set xtics rotate by 90 offset 0,-4 out nomirror
set bmargin at screen 0.2
set xtics rotate by 90 right

set xdata time
set yrange [0:360]
set ytics 45
set y2range [0:360]
set y2tics 45

set ylabel "Wind direction (Degrees from true N)"
set y2label rotate by -90 
set y2label "Wind direction (Degrees from true N)"
set title "Average Wind Direction"
plot FILE using 1:12 title 'Average Wind Direction' with points pointtype 7 pointsize 1

unset multiplot

当我将yrange从[0:750]更改为[0:360]时,如何防止背景图像重新缩放?

任何帮助将不胜感激,提前谢谢。

1 个答案:

答案 0 :(得分:1)

你的剧本中有一些奇怪的东西:

  1. 只有在绘制背景图像后才设置输出文件,这是错误的。

  2. 根据您的评论,您希望背景图像覆盖整个图像,而不仅仅是绘图区域,这是否正确?

  3. 我认为,背景图像应仅覆盖绘图区域。

    我猜你遇到的问题与自动保证金计算有关。在绘制背景图像时,您没有标签和不同的tic长度,因此第一个绘图的自动计算边距与第二个绘图的边距不同。

    您必须为所有四个边距设置固定值,就像您对bmargin所做的那样。以下脚本应该可以工作(我无法测试它,因为我没有测试数据):

    set terminal png size 1000,750
    set output "winddir.png"
    
    set multiplot
    
    set autoscale xfix
    set autoscale yfix
    unset tics
    unset border
    set lmargin at screen 0.175
    set rmargin at screen 0.9
    set bmargin at screen 0.2
    set tmargin at screen 0.9
    
    plot "plot_backgrnd2.png" binary filetype=png w rgbimage notitle 
    
    set xtics rotate by 90 right
    
    set xdata time
    set yrange [0:360]
    set ytics 45
    set y2range [0:360]
    set y2tics 45
    
    set ylabel "Wind direction (Degrees from true N)"
    set y2label rotate by -90 
    set y2label "Wind direction (Degrees from true N)"
    set title "Average Wind Direction"
    plot FILE using 1:12 title 'Average Wind Direction' with points pointtype 7 pointsize 1
    
    unset multiplot