how to draw objects (rect) from a file

橙三吉。 提交于 2019-12-23 14:53:43

问题


In gnuplot i can draw a rectangle via

set object rect from x0,y0 to x1,y1

How to read the coordinates x0,x1,y0,y1 from a file?


回答1:


One way would be to put the line of code that sets the rectangle into a separate file and call that file from within the gnuplot script. So you have a file called "coord.txt" that contains the one line

set object rect from 2,2 to 4,40

and you have a gnuplot script called "rect.gp" that says

set title "call rectangle coordinates"
load "coord.txt"
plot x**2

If you now from within gnuplot type load "rect.gp" you get your graph with the rectangle.

That may not be exactly what you are looking for but maybe a first step.




回答2:


You probably need to store the data from the file into variables, then use these variables to define the locations of objects. The way to do this is not straight as far as I know. Please refer to here. Good luck!



来源:https://stackoverflow.com/questions/8521824/how-to-draw-objects-rect-from-a-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!