【发布时间】:2016-04-13 21:07:23
【问题描述】:
我正在尝试在 png 文件中绘制多图。多图有 8 个图。每个图都有两个 y 轴,网格将用 ls 0 显示。一切正常,直到我更改图的线宽。当我直接在绘图中更改线型或线宽时,其余绘图中的网格以新的线宽和颜色显示。我在 Windows 7 MinGW 中使用 GNU Plot 版本 5。
我已经尝试过在网格中设置线条样式,如下所示:
1。 设置样式第 4 行 lc rgb 'black' lt 0 设置网格 xtics ytics y2tics ls 4
- 在绘图时设置线宽,如下所示: input_filename 使用 11:9 线轴 x1y2 lc rgb 'green' lw 2 title 'Plot-5'
但是没有任何效果。以下是完整代码:
#----------------
#input variables
#----------------
#input_filename
#png_filename
#----------------
# Sample Command:
#
# gnuplot -e "input_filename='test.csv'" -e "png_filename='test.png'" gnuplotMultiSample_A.plt
#
#----------------
#----------------
# Code Starts
#----------------
reset
set datafile separator ","
set term png
set output png_filename
set size 1,2
set terminal png size 2560,1920
set ytics nomirror
set y2tics
set multiplot layout 4,2 columnsfirst title png_filename
set style line 1 lc rgb 'red' lt 3
set style line 2 lc rgb 'blue' lt 2 lw 2
set style line 3 lc rgb 'green' lt 1
set style line 4 lc rgb 'black' lt 0
unset grid
#set grid xtics ytics y2tics lt 0 lc rgb "#880000"
set grid xtics ytics y2tics ls 4
plot input_filename using 11:12 with lines axes x1y1 ls 1 title 'Actual', \
input_filename using 11:1 with lines axes x1y2 lc rgb 'green' title 'Plot-1'
plot input_filename using 11:12 with lines axes x1y1 ls 1 title 'Actual', \
input_filename using 11:3 with lines axes x1y2 ls 2 title 'Plot-2'
plot input_filename using 11:12 with lines axes x1y1 ls 1 title 'Actual', \
input_filename using 11:5 with lines axes x1y2 ls 3 title 'Plot-3'
plot input_filename using 11:12 with lines axes x1y1 ls 1 title 'Actual', \
input_filename using 11:7 with lines axes x1y2 ls 4 title 'Plot-4'
plot input_filename using 11:12 with lines axes x1y1 ls 1 title 'Actual', \
input_filename using 11:9 with lines axes x1y2 lc rgb 'green' title 'Plot-5'
plot input_filename using 11:12 with lines axes x1y1 ls 1 title 'Actual', \
input_filename using 11:11 with lines axes x1y2 lc rgb 'green' title 'Plot-6'
plot input_filename using 11:12 with lines axes x1y1 ls 1 title 'Actual', \
input_filename using 11:1 with lines axes x1y2 lc rgb 'green' title 'Plot-7'
plot input_filename using 11:12 with lines axes x1y1 ls 1 title 'Actual', \
input_filename using 11:3 with lines axes x1y2 lc rgb 'green' title 'Plot-8'
unset grid
unset multiplot
使用 pngcairo。以下是最终代码供参考。谢谢肖尔施。
#----------------
#input variables
#----------------
#input_filename
#png_filename
#----------------
# Sample Command:
#
# gnuplot -e "input_filename='test.csv'" -e "png_filename='test.png'" gnuplotMultiSample_A.plt
#
#----------------
#----------------
# Code Starts
#----------------
reset
set term pngcairo size 2560,1920
#set terminal pngcairo dashed
#set termoption dashed
set datafile separator ","
#set term png
set output png_filename
set size 1,2
#set terminal png size 2560,1920
set ytics nomirror
set y2tics
set multiplot layout 4,2 columnsfirst title png_filename
set style line 81 lc rgb 'red' lt 3 lw 1
set style line 82 lc rgb 'blue' lt 2 lw 2
set style line 83 lc rgb 'green' lt 1 lw 1
set style line 84 lc rgb 'black' lt 0 lw 1
unset grid
#set grid xtics ytics y2tics lt 0 lc rgb "#880000"
#set grid xtics ytics y2tics lt 1 lw 1 lc rgb "#880000"
# Line type 1 works for Png but not lt 0. As per the guidelines
# trying using "set terminal pngcairo dashed" as per the site:
# http://stackoverflow.com/questions/19412382/gnuplot-line-types/19420678#19420678
# http://stackoverflow.com/questions/34689654/grid-lines-are-changed-in-multiplot-if-lines-styles-of-y-column-is-changed/34751992#34751992
set grid xtics ytics y2tics lt 0 lw 1 lc rgb "#880000"
plot input_filename using 11:12 with lines axes x1y1 ls 81 title 'Actual', \
input_filename using 11:1 with lines axes x1y2 lc rgb 'green' title 'Plot-1'
plot input_filename using 11:12 with lines axes x1y1 ls 81 title 'Actual', \
input_filename using 11:3 with lines axes x1y2 ls 82 title 'Plot-2'
plot input_filename using 11:12 with lines axes x1y1 ls 81 title 'Actual', \
input_filename using 11:5 with lines axes x1y2 ls 83 title 'Plot-3'
plot input_filename using 11:12 with lines axes x1y1 ls 81 title 'Actual', \
input_filename using 11:7 with lines axes x1y2 ls 84 title 'Plot-4'
plot input_filename using 11:12 with lines axes x1y1 ls 81 title 'Actual', \
input_filename using 11:9 with lines axes x1y2 lc rgb 'green' title 'Plot-5'
plot input_filename using 11:12 with lines axes x1y1 ls 81 title 'Actual', \
input_filename using 11:11 with lines axes x1y2 lc rgb 'green' title 'Plot-6'
plot input_filename using 11:12 with lines axes x1y1 ls 81 title 'Actual', \
input_filename using 11:1 with lines axes x1y2 lc rgb 'green' title 'Plot-7'
plot input_filename using 11:12 with lines axes x1y1 ls 81 title 'Actual', \
input_filename using 11:3 with lines axes x1y2 lc rgb 'green' title 'Plot-8'
unset grid
unset multiplot
【问题讨论】:
-
很高兴它成功了。您不一定必须在问题中包含答案(如果您愿意,可以);但答案不会出现在问题不在的任何地方。如果它只包含您的原始代码,它可能会使您的问题更具可读性。我会把它留给你。
标签: gnuplot