Page 1 of 1

Draw polyline problem

Posted: 2011-05-26T01:25:03-07:00
by Bonzo
I am drawing a line graph and currently have to use -flip as it is drawn upside down; any idea whats going on ?

Code: Select all

convert -size 800x500 xc:none -fill none -stroke Red -strokewidth 1 -gravity southwest -draw "polyline 100,260 150,290 200,380 250,310 300,400 350,210 " test.png

Re: Draw polyline problem

Posted: 2011-05-26T09:39:01-07:00
by fmw42
Y image coordinates are at the top of the image and increase downward. The X,Y origin is at the top left.

You can flip the resulting image or you can recompute your Y coordinates as Height-Y-1.

Re: Draw polyline problem

Posted: 2011-05-26T10:36:26-07:00
by Bonzo
So using -gravity southwest has no effect in this case ?

Re: Draw polyline problem

Posted: 2011-05-26T11:43:36-07:00
by fmw42
Bonzo wrote:So using -gravity southwest has no effect in this case ?
Not that I know! But I will defer to the IM developers for a definitive answer.

I believe that only -draw "text... and -draw "image over... are gravity sensitive. see http://www.imagemagick.org/Usage/draw/#primitives

Re: Draw polyline problem

Posted: 2011-05-26T11:55:59-07:00
by Bonzo
Thanks Fred I have modified my code so that the lines are drawn then the image is flipped before adding the text.

THE DATA FOR THE LINES IS MADE UP NOT ACTUAL !
Image

At a guess it takes 2 seconds to create the image above on my PC. I have removed all the tempory images but one but it had little effect.

Re: Draw polyline problem

Posted: 2011-05-26T11:59:35-07:00
by fmw42
I look forward to seeing your real comparison results graphed.

Re: Draw polyline problem

Posted: 2011-05-26T12:09:48-07:00
by Bonzo
I have hit a bit of a hurdle at the moment on how to scale and annotate the vertical axis; I will also need to tidy up the code. This was basicaly an exercise to try writing a php class to create a line graph.

Re: Draw polyline problem

Posted: 2011-05-26T12:29:21-07:00
by fmw42
Have you considered using Gnuplot. see http://www.gnuplot.info/

Re: Draw polyline problem

Posted: 2011-05-26T13:54:40-07:00
by Bonzo
I looked at gnuplot once before but it is more complicated than I need; also as I say once I get it working how I want I am going to try to convert it to a php class just to try try out writing a class.

Re: Draw polyline problem

Posted: 2011-05-26T18:46:57-07:00
by anthony
Bonzo wrote:So using -gravity southwest has no effect in this case ?
Gravity positioning only effects text and images, and in these cases also effects justification around the position point.

Gravity is not actually part of SVG standard and as such typically used for drawing.

This is noted at the end of the IM examples, Drawing, Primitives, text and image
http://www.imagemagick.org/Usage/draw/#primitive_text

Re: Draw polyline problem

Posted: 2011-05-26T18:50:26-07:00
by anthony
Bonzo wrote:I looked at gnuplot once before but it is more complicated than I need; also as I say once I get it working how I want I am going to try to convert it to a php class just to try try out writing a class.
As a user (and old programmer) of gnuplot, it isn't really very complicated. Just get a small example and follow it.
The real problem is that it does not have a very good help mechanism, and usage examples is more of a 'find what you like and study it'

The best idea with gnuplot is keep it simple as long as you can.