use perl to draw Venn Diagram

Discussion in 'Perl Misc' started by Ela, Apr 28, 2008.

  1. Ela

    Ela Guest

    Perl has a GD library. But its circle, arc, line and alike seem to have
    limited applications.

    I just want to plot 2 circles, one with solid line and another with dotted
    line, overlapping with each other according to an input overlapping
    parameter (I guess this feature may be achieved by locating the 2 centers
    accordingly). Finally write some texts in the centers of the 2 circles. Any
    suggestions? Matlab can achieve that easily and is Perl really unable to do
    that?
     
    Ela, Apr 28, 2008
    #1
    1. Advertising

  2. Ela wrote:
    > Perl has a GD library.


    No. Perl has an interface to the GD Graphics Library.

    http://search.cpan.org/perldoc?GD

    > But its circle, arc, line and alike seem to have limited applications.


    How did you come to that conclusion?

    > I just want to plot 2 circles, one with solid line and another with dotted
    > line, overlapping with each other according to an input overlapping
    > parameter (I guess this feature may be achieved by locating the 2 centers
    > accordingly). Finally write some texts in the centers of the 2 circles.


    Interesting. Have you written any code yet?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Apr 28, 2008
    #2
    1. Advertising

  3. Ela

    Ela Guest

    >> I just want to plot 2 circles, one with solid line and another with
    >> dotted line, overlapping with each other according to an input
    >> overlapping parameter (I guess this feature may be achieved by locating
    >> the 2 centers accordingly). Finally write some texts in the centers of
    >> the 2 circles.

    >
    > Interesting. Have you written any code yet?
    >
    > --
    > Gunnar Hjalmarsson
    > Email: http://www.gunnar.cc/cgi-bin/contact.pl


    In Matlab, I can specify parameters like: LineWidth, LineStyle and so. I'm
    not asking others to post their codes but would like to know whether such
    parameters exist or not. Because after reading

    Graphics_Programming_with_Perl by Martien_Verbruggen-Manning

    I did not find any clues.
     
    Ela, Apr 28, 2008
    #3
  4. Ela wrote:
    > Gunnar Hjalmarsson wrote:
    >> Ela wrote:
    >>> I just want to plot 2 circles, one with solid line and another with
    >>> dotted line, overlapping with each other according to an input
    >>> overlapping parameter (I guess this feature may be achieved by
    >>> locating the 2 centers accordingly). Finally write some texts in the
    >>> centers of the 2 circles.

    >>
    >> Interesting. Have you written any code yet?

    >
    > In Matlab, I can specify parameters like: LineWidth, LineStyle and so. I'm
    > not asking others to post their codes but would like to know whether such
    > parameters exist or not.


    Then read the docs for GD.pm (link provided in my previous message).

    > Because after reading
    >
    > Graphics_Programming_with_Perl by Martien_Verbruggen-Manning
    >
    > I did not find any clues.


    But you didn't read the GD.pm docs, right?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Apr 28, 2008
    #4
  5. "Ela" <> writes:

    > In Matlab, I can specify parameters like: LineWidth, LineStyle and so. I'm
    > not asking others to post their codes but would like to know whether such
    > parameters exist or not. Because after reading
    >
    > Graphics_Programming_with_Perl by Martien_Verbruggen-Manning
    >
    > I did not find any clues.


    GD can do that. Read its docs.

    Personally, I prefer Cairo...

    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
     
    Joost Diepenmaat, Apr 28, 2008
    #5
  6. Ela

    zentara Guest

    On Mon, 28 Apr 2008 07:59:55 +0800, "Ela" <> wrote:

    >Perl has a GD library. But its circle, arc, line and alike seem to have
    >limited applications.
    >
    >I just want to plot 2 circles, one with solid line and another with dotted
    >line, overlapping with each other according to an input overlapping
    >parameter (I guess this feature may be achieved by locating the 2 centers
    >accordingly). Finally write some texts in the centers of the 2 circles. Any
    >suggestions? Matlab can achieve that easily and is Perl really unable to do
    >that?


    Yeah, see my replies in http://perlmonks.org?node_id=502389 for ways to
    do it with Tk, Gtk2, and Tk::Zinc.

    Writing text is a simple addition. You can also save the Canvases if
    desired to a pdf or jpg, etc, and you can add mouse-dragging if wanted.

    zentara


    --
    I'm not really a human, but I play one on earth.
    http://zentara.net/japh.html
     
    zentara, Apr 28, 2008
    #6
  7. Ela

    Ela Guest

    > Then read the docs for GD.pm (link provided in my previous message).
    >
    >> Because after reading
    >>
    >> Graphics_Programming_with_Perl by Martien_Verbruggen-Manning
    >>
    >> I did not find any clues.

    >
    > But you didn't read the GD.pm docs, right?
    >
    > --

    Thanks a lot, Gunnar Hjalmarsson. But the doc and google search don't tell
    me how to use gdstyled and gdbrushed to draw a circle with a dashed/dotted
    line.
     
    Ela, Apr 28, 2008
    #7
  8. Ela

    Ela Guest

    > Yeah, see my replies in http://perlmonks.org?node_id=502389 for ways to
    > do it with Tk, Gtk2, and Tk::Zinc.
    >
    > Writing text is a simple addition. You can also save the Canvases if
    > desired to a pdf or jpg, etc, and you can add mouse-dragging if wanted.
    >

    Thanks, zentara. Instead of drawing a sophisticated Venn diagram like yours,
    I just need simple ones. And the fatal error is that I can't install
    X-related onto computer. Is there any workaround? I need to produce ~1000
    Venn diagrams...
     
    Ela, Apr 28, 2008
    #8
  9. "Ela" <> writes:

    > Thanks a lot, Gunnar Hjalmarsson. But the doc and google search don't tell
    > me how to use gdstyled and gdbrushed to draw a circle with a dashed/dotted
    > line.


    The following is copied directly from the getStyle section of the GD
    docs at <http://search.cpan.org/~lds/GD-2.39/GD.pm>:

    # Set a style consisting of 4 pixels of yellow,
    # 4 pixels of blue, and a 2 pixel gap
    $myImage->setStyle($yellow,$yellow,$yellow,$yellow,
    $blue,$blue,$blue,$blue,
    gdTransparent,gdTransparent);
    $myImage->arc(50,50,25,25,0,360,gdStyled);

    You could probably also use brushes instead. Anyway all the
    information is really there in the docs. If you're unable to create a
    working script from that, you may want to post at least what you've
    got now and what you're having difficulty with *exactly*. Just
    claiming GD doesn't do what you want when it clearly does and even
    provide examples in the docs isn't helping.

    Take some time to read the full manpage linked above, it's not that
    big and you should be able to figure it out yourself.

    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
     
    Joost Diepenmaat, Apr 28, 2008
    #9
  10. Ela

    Ela Guest

    > You could probably also use brushes instead. Anyway all the
    > information is really there in the docs. If you're unable to create a
    > working script from that, you may want to post at least what you've
    > got now and what you're having difficulty with *exactly*. Just
    > claiming GD doesn't do what you want when it clearly does and even
    > provide examples in the docs isn't helping.
    >
    > Take some time to read the full manpage linked above, it's not that
    > big and you should be able to figure it out yourself.
    >

    I feel sorry for not understanding what "holes" refer to... Not
    complimenting Matlab, but I am used to its elegant library to provide
    intuitive and powerful functions... Certainly, GD provides a greater control
    over how wide the holes can be...
     
    Ela, Apr 28, 2008
    #10
  11. Ela

    zentara Guest

    On Mon, 28 Apr 2008 23:55:57 +0800, "Ela" <> wrote:

    >> You could probably also use brushes instead. Anyway all the
    >> information is really there in the docs. If you're unable to create a
    >> working script from that, you may want to post at least what you've
    >> got now and what you're having difficulty with *exactly*. Just
    >> claiming GD doesn't do what you want when it clearly does and even
    >> provide examples in the docs isn't helping.
    >>
    >> Take some time to read the full manpage linked above, it's not that
    >> big and you should be able to figure it out yourself.
    >>

    >I feel sorry for not understanding what "holes" refer to... Not
    >complimenting Matlab, but I am used to its elegant library to provide
    >intuitive and powerful functions... Certainly, GD provides a greater control
    >over how wide the holes can be...
    >


    If you need to do this without X, you might want to look at the Cairo
    module
    http://cairographics.org/samples/

    You can save them to many file formats. Gtk2's graphics are based
    on Cairo.

    zentara

    --
    I'm not really a human, but I play one on earth.
    http://zentara.net/japh.html
     
    zentara, Apr 29, 2008
    #11
  12. Ela

    Ted Zlatanov Guest

    On Tue, 29 Apr 2008 12:31:06 GMT zentara <> wrote:

    z> On Mon, 28 Apr 2008 23:55:57 +0800, "Ela" <> wrote:
    >>> You could probably also use brushes instead. Anyway all the
    >>> information is really there in the docs. If you're unable to create a
    >>> working script from that, you may want to post at least what you've
    >>> got now and what you're having difficulty with *exactly*. Just
    >>> claiming GD doesn't do what you want when it clearly does and even
    >>> provide examples in the docs isn't helping.
    >>>
    >>> Take some time to read the full manpage linked above, it's not that
    >>> big and you should be able to figure it out yourself.
    >>>

    >> I feel sorry for not understanding what "holes" refer to... Not
    >> complimenting Matlab, but I am used to its elegant library to provide
    >> intuitive and powerful functions... Certainly, GD provides a greater control
    >> over how wide the holes can be...
    >>


    z> If you need to do this without X, you might want to look at the Cairo
    z> module
    z> http://cairographics.org/samples/

    z> You can save them to many file formats. Gtk2's graphics are based
    z> on Cairo.

    Also the OP may want to consider Matlab's own scripting abilities which
    are pretty decent.

    Ted
     
    Ted Zlatanov, Apr 30, 2008
    #12
  13. On Apr 30, 2:17 pm, Ted Zlatanov <> wrote:
    > On Tue, 29 Apr 2008 12:31:06 GMT zentara <> wrote:
    >
    > z> On Mon, 28 Apr 2008 23:55:57 +0800, "Ela" <> wrote:
    >
    > >>> You could probably also use brushes instead. Anyway all the
    > >>> information is really there in the docs. If you're unable to create a
    > >>> working script from that, you may want to post at least what you've
    > >>> got now and what you're having difficulty with *exactly*. Just
    > >>> claiming GD doesn't do what you want when it clearly does and even
    > >>> provide examples in the docs isn't helping.

    >
    > >>> Take some time to read the full manpage linked above, it's not that
    > >>> big and you should be able to figure it out yourself.

    >
    > >> I feel sorry for not understanding what "holes" refer to... Not
    > >> complimenting Matlab, but I am used to its elegant library to provide
    > >> intuitive and powerful functions... Certainly, GD provides a greater control
    > >> over how wide the holes can be...

    >
    > z> If you need to do this without X, you might want to look at the Cairo
    > z> module
    > z>http://cairographics.org/samples/
    >
    > z> You can save them to many file formats. Gtk2's graphics are based
    > z> on Cairo.
    >
    > Also the OP may want to consider Matlab's own scripting abilities which
    > are pretty decent.


    Really? I have only cursory experience with Matlab, which was used in
    a genomics course I took, but I wasn't very impressed. Guess I didn't
    look closely enough at it.
     
    nolo contendere, Apr 30, 2008
    #13
  14. Ela

    Ted Zlatanov Guest

    On Wed, 30 Apr 2008 11:23:07 -0700 (PDT) nolo contendere <> wrote:

    nc> On Apr 30, 2:17 pm, Ted Zlatanov <> wrote:

    >> Also the OP may want to consider Matlab's own scripting abilities which
    >> are pretty decent.


    nc> Really? I have only cursory experience with Matlab, which was used in
    nc> a genomics course I took, but I wasn't very impressed. Guess I didn't
    nc> look closely enough at it.

    It's pretty decent for what it does. For example, you can easily loop
    over N values and do a plot that depends on the current value, which is
    what the OP wanted. There's nntp:comp.soft-sys.matlab too.

    See:

    http://www.math.ucdavis.edu/~sawilliams/MATLABguide.html
    http://physics.gac.edu/~huber/envision/tutor2/mtlscrip.htm

    .... and many other M-file examples Google returned, plus Mathworks' own site ...

    Note I use "scripts" when I mean functions as well in the Matlab
    context.

    Ted
     
    Ted Zlatanov, Apr 30, 2008
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ingmar Seifert

    tool to draw FSM bubble diagram

    Ingmar Seifert, Jul 31, 2003, in forum: VHDL
    Replies:
    5
    Views:
    23,384
    Pedro Claro
    Aug 1, 2003
  2. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    0
    Views:
    368
    =?Utf-8?B?ZGF2aWQ=?=
    Feb 16, 2006
  3. Dorren
    Replies:
    0
    Views:
    754
    Dorren
    Apr 1, 2007
  4. Bobby Edward

    Class Diagram - Do you use it?

    Bobby Edward, Sep 17, 2008, in forum: ASP .Net
    Replies:
    5
    Views:
    444
  5. phil
    Replies:
    0
    Views:
    142
Loading...

Share This Page