我正在尝试获取不同的点颜色,并在同一张图中输入x轴上第二个文件的点。
我有两个不同的文件,其中包含:(y轴:D,A,Q,F;x轴: 1-5和6-10) 1.文件enter image description here 2.文件enter image description here
然后我写了这段代码来绘制:
set style data labels
xcoord(N)= (N)
ycoord(N) = (column(0)+1)
symbol(N) = strcol(N) ne "/" ? strcol(N) : "/"
set xrange [0:10]
set yrange [0:5]
set ytics ("D" 1, "A" 2, "Q" 3, "F" 4)
plot for [N=0:6] 'doc.txt' using (xcoord(N)):(ycoord(N)):(symbol(N)):(symbol(N)) w labels tc lt 7 font "Helvetica,12" notitle, \
for [N=0:6] 'doc1.txt' using (xcoord(N)):(ycoord(N)):(symbol(N)):(symbol(N)) w labels tc lt 1 font "Helvetica,10" notitle目前的输出是这样的: graph of 1.file enter image description here两个数据文件的graph enter image description here
如你所见,所有的点都是重叠的。我想对/、5、g、3和o使用不同的颜色,并在x轴6-10上绘制第二个文件的点。我该怎么做呢?有人能帮我纠正一下我的命令吗。非常感谢。
发布于 2021-06-01 00:59:44
我不确定我完全理解这个问题,但是要将第二个文件中的点在x上移动六个单位,您可以将plot命令修改为:
plot for [N=0:6] 'doc.txt' using (xcoord(N)):(ycoord(N)):(symbol(N)):(symbol(N)) w labels tc lt 7 font "Helvetica,12" notitle, \
for [N=0:6] 'doc1.txt' using (6+xcoord(N)):(ycoord(N)):(symbol(N)):(symbol(N)) w labels tc lt 1 font "Helvetica,10" notitle你能澄清一下你想用什么颜色的点吗?您的示例输出确实为每个文件中的点使用了不同的颜色;这不是您想要的吗?
编辑
我正在编造一个数据格式,因为您还没有显示任何实际数据,但也许下面的示例足以让您开始使用。
$DATA << EOD
3 F / / 3 g 3
2 Q / / o / 5
1 A / o / / 5
0 D / / 5 / g
EOD
set xrange [0:7]
set yrange [-1:4]
set tics nomirror
set border 3
unset key
# These are the hexadecimal RGB representations of
# "red" "blue" "yellow" "green" "purple"
array colors = [0xFF0000, 0x0000FF, 0xFFFF00, 0x00FF00, 0xC080FF]
array symbol = ["/", "5", "g", "3", "o"]
color( sym ) = sum [i=1:5] (symbol[i] eq sym ? colors[i] : 0)
plot for [N=1:6] $DATA using (N) : (column(1)) : (strcol(N)) : (color(strcol(N))) \
with labels tc rgb variable font ":Bold"

或者,您可以使用调色板颜色和数值,而不是离散的RGB颜色名称。这将是一种不同的方法。
发布于 2021-06-01 04:54:57
非常感谢你的回答。这非常非常有帮助。在此处输入镜像描述1:https://i.stack.imgur.com/gLuoF.png
我现在可以看到我的图表,我想要的东西。
祝你晚上愉快,!:)
非常感谢,
张。
https://stackoverflow.com/questions/67774062
复制相似问题