如何在 Gnuplot 中指示具有不同点类型的标签?
假设我有想要在文件“animals.txt”中绘制的数据:
cat 5.2 1.0
cat 5.4 1.3
cat 5.2 1.2
dog 3.8 1.1
dog 3.5 1.5
dog 3.6 1.3
giraffe 1.3 9.7
giraffe 1.5 9.0
giraffe 1.4 9.9
我可以使用标签生成散点图:
plot "animals.txt" u 2:3:1 w labels
我还可以使用以下内容改变每个点的样式:
plot "animals.txt" u 2:3 w points pointtype 3
而不是使用标签(其中可能重叠),是否可以让点为每个类别使用不同的点类型或颜色? (例如,使用 pointtype 3 时“cat”将显示为红色,使用 pointtype 4 时“dog”将显示为蓝色,等等)
我可以使用“lc 变量”并用颜色替换标签列,但我的文件与太多不同的标签一起工作对我来说很难做到这一点。
Let's say I have data I'd like to be plotted in a file "animals.txt":
cat 5.2 1.0
cat 5.4 1.3
cat 5.2 1.2
dog 3.8 1.1
dog 3.5 1.5
dog 3.6 1.3
giraffe 1.3 9.7
giraffe 1.5 9.0
giraffe 1.4 9.9
I can generate a scatter plot with labels using:
plot "animals.txt" u 2:3:1 w labels
I can also vary the style of each point using something like:
plot "animals.txt" u 2:3 w points pointtype 3
Instead of using labels (which might overlap), is it possible to have the points use different point types or colors for each category? (For instance, "cat" would be in red using pointtype 3, "dog" would be in blue using pointtype 4, etc.)
I could use "lc variable" and replace the labels column with colors, but the file I'm working with has too many different labels for me to do that easily.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为没有办法直接做到这一点。
然而,一个简单的解决方法是使用 gnuplot 的 awk 接口。然后,您可以绘制 3 个单独的图表,每只动物一个。
由于每行之间的唯一区别是动物的名称,因此您可能可以用更好的方式编写脚本,但您明白了,
汤姆
I don't think there is a way to do this directly.
However, an easy fix is to use gnuplot's interface to awk. You can then plot 3 separate graphs, one for each animal.
Since the only difference between each line is the name of the animal, you could probably script this in a better way, but you get the idea,
Tom