I am searching for an easy way to plot about 10 points and rectangles to be able to see where my algorithm goes wrong. I had a look at gnuplot, but it seems it is particularly bad a plotting rectangles.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
SVG (MDN Tutorial) is a very simple text-based (XML) format that you can emit easily using Ruby without any SVG library and view in any modern web browser. Here’s one example:
SVG Points via String Interpolation
Output: http://jsfiddle.net/xwnVY/
If you want to be more structured than string interpolation:
SVG Points Using Nokogiri XML Builder
Save the output as “foo.svg” and open it in a modern web browser to view.
Drawing Rects
To draw rects, you can use any of:
The polygon may be the easiest to produce if you want to connect arbitrary points that are not axis-aligned without worrying about transforms. Note that while I’ve shown the coordinates above in the format
x,y x,yfor clarity, SVG will also acceptx,y,x,yorx y x y, if those are easier for your code to generate.A Bit of Formatting
If you want to draw outlines instead of filled shapes, you can add this CSS in your SVG:
Using Haml for the XML
Finally, Haml is another option that you might consider for making your XML without an SVG-specific library:
Output: http://jsfiddle.net/xwnVY/4/