ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
Subject: Re: Venn diagram
Date: Fri, 20 Jan 2006 00:49:43 -0500 (EST)	[thread overview]
Message-ID: <Pine.WNT.4.63.0601200042300.704@nqvgln> (raw)
In-Reply-To: <C423E7A7-AB6E-4A90-BF24-CCED1E41D5B2@cox.net>

<--- On Jan 19, David Arnold wrote --->

> All,
>
> I have:
>
> \startMPpage   %figure library name: intersection
>
>  %initialize scale
>  numeric u; 10u=3in;
>
>  %ellipses
>  path A, B;
>  A:=fullcircle xyscaled (4u,3u);
>  B:=A shifted (2u,0);
>  draw A withcolor red;
>  label.ulft(btex $A$ etex, point 3 of A) withcolor red;
>  draw B withcolor blue;
>  label.urt(btex $B$ etex, point 1 of B) withcolor blue;
>
>  %bounding box
>  draw bbox currentpicture enlarged (0.5u,0.5u);
>
> \stopMPpage
>
> I need an easy way of shading these areas:
>
> 1. A intersect B
> 2. A union B
> 3. A intersect (complement of B)
> 4. (complement of A) intersect B

There is venn.mp on ctan. Using it you can do basic shading of 
intersection, union etc for 0,1,2 or 3 sets very quickly. Read the 
documentation in source for details. For example

\startMPinclusions
   input venn;
   pair A,B,T[];
   A = (.4venn_width-.5venn_circle_diameter,.5venn_height);
   B = (.6venn_width+.5venn_circle_diameter,.5venn_height);
   T1 = (.5venn_width , 0);
   T2 = (.5venn_width,.5venn_height-.5venn_circle_diameter);
   vardef venn_shade = red;
\stopMPinclusions


\startMPpage
  draw_venn_two(false,true,true,true);
  label.lft(btex $A$ etex,A);
  label.rt(btex $B$ etex,B);
  label.bot(btex $A\cup B$ etex,T2);
\stopMPpage

\startMPpage
  draw_venn_two(false,false,true,false);
  label.lft(btex $A$ etex,A);
  label.rt(btex $B$ etex,B);
  label.bot(btex $A\cap B$ etex,T2);
\stopMPpage

\startMPpage
  draw_venn_two(true,false,false,false);
  label.lft(btex $A$ etex,A);
  label.rt(btex $B$ etex,B);
  label.bot(btex $A'\cap B'$ etex,T2);
\stopMPpage


Perhaps one can combine the transparent color functionality of 
metapost with venn.mp to get really nice colors for intersections etc.

Another related question, does anyone know of a good way to hash 
(hatch) a "set" (in general, any mp closed curve). I know that there 
is hatching.mp but I was wondering if there are better solutions.

Aditya

-- 
Aditya Mahajan, EECS Systems, University of Michigan
http://www.eecs.umich.edu/~adityam || Ph: 7342624008

  reply	other threads:[~2006-01-20  5:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-20  5:08 David Arnold
2006-01-20  5:49 ` Aditya Mahajan [this message]
2006-01-20 18:22   ` Mojca Miklavec
2006-01-20 20:23     ` Hans Hagen
2006-01-20 23:33       ` Mojca Miklavec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.WNT.4.63.0601200042300.704@nqvgln \
    --to=adityam@umich.edu \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).