Martin Buchmann | 7 Nov 17:58 2003
Picon
Picon

A problem with graph.mp

Hi,

i'm thinking about using metapost to draw some 
graphs from data. I tried the graph package and 
it looks very good. But i now i'm running into 
some trouble. I want to draw a data set twice, 
one time with dots and one time with a line.

So i tried:

prologues:=1;

input graph

beginfig(1);
draw begingraph(10cm,10cm);
gdraw "alcu-phd.dat" plot btex $\bullet$ etex withpen pencircle;
endgraph;
endfig;
end

as suggested in the manual. FYI my data looks like this:

<--- alcu-phd.dat --->

0.000  660.45  liquidus: wt\% Cu, T
0.492  657.45
0.988  654.45
1.486  651.45
1.987  648.45
(Continue reading)

Maurizio Vianello | 7 Nov 18:06 2003
Picon

Line in rectangle

Dear Fellow MP users:

I have defined  a path which is simply a rectangle, let's call it "border".

I want to define a macro which, given as inputs the coordinates of two 
points inside the rectangle,  would draw a line through the two points up 
to the border, and not further. I have been able to do that, but I don't 
like very much my solution ( I used the "clip currentpicture to" command). 
Is there an "elegant" way to do this? Thanks for any suggestions.

Moreover, I have a simple question: Is there any way one could redifine the 
basic unit of MP so that, for instance (2,3) means (2cm,3cm), without using 
a construction like unit*(2,3). I mean: is ther a way to tell MP from  the 
beginning that I want my basic unit to be cm (for instance).

As you can see I am not very experienced but I am trying hard.
Thanks.

Ciao,
Maurizio
Palle Jørgensen | 9 Nov 21:45 2003
Picon

Re: A problem with graph.mp

Martin Buchmann <Martin_Buchmann <at> gmx.net> writes:

[snip]
> So i tried:
>
> prologues:=1;
>
> input graph
>
> beginfig(1);
> draw begingraph(10cm,10cm);
> gdraw "alcu-phd.dat" plot btex $\bullet$ etex withpen pencircle;
> endgraph;
> endfig;
> end
>
> But in the resulting diagramm the dots are all a bit shifted so that
> the line is not superimposed as mentioned in the manual.

The problem with the "plot" macro is, that the inserted picture is put
in with the lower left corner at the data point.

You can use the following:

def picplot expr P =
  plot P shifted .5(llcorner.P-urcorner.P)
enddef;

beginfig(1);
  draw begingraph(10cm,10cm);
(Continue reading)

Martin Buchmann | 10 Nov 10:54 2003
Picon
Picon

Re: A problem with graph.mp

Palle,

thanks for your answer. That solves my problem. 
But i found another solution on Vincent 
Zoonekynd's examples page. And now i draw a 
circle directly in Metapost instead of calling 
TeX.

>picture rot;
>
>draw(0,0) withpen pencircle scaled 4bp withcolor red;
>rot := currentpicture;
>currentpicture := nullpicture;

and later

>gdraw "file" plot rot withpen pencircle withcolor red;

In my opion that makes more sense than calling 
TeX to get a circle. Or is there any problem 
which i don't see at the moment?

Regards
   Martin

--

-- 
Schlagfertige Repliken für jede Gelegenheit #3
Das hat schon mal jemand zu mir gesagt, da ist mir auch nichts eingefallen.
				http://www.titanic-magazin.de
(Continue reading)

Jens-Uwe Morawski | 10 Nov 14:01 2003
Picon
Picon

Re: Line in rectangle

On Fri, 07 Nov 2003 18:06:50 +0100
Maurizio Vianello <mvs52 <at> lombardiacom.it> wrote:

> Dear Fellow MP users:
> 
> I have defined  a path which is simply a rectangle, let's call it "border".
> 
> I want to define a macro which, given as inputs the coordinates of two 
> points inside the rectangle,  would draw a line through the two points up 
> to the border, and not further.

path border ; border := unitsquare xscaled 5cm yscaled 3cm ;

def Macro(expr a, e)=
  draw (border intersectionpoint
    ((a+(infinity*unitvector(a-e)))--a))--
  (border intersectionpoint
    (e--(e+(infinity*unitvector(e-a))))) ;
enddef;

beginfig(1);
  draw border ;
  Macro ((1.1cm,2.5cm),(2cm,1cm)) ;
  Macro ((2cm,2.5cm),(1cm,2cm)) ;
  Macro ((1mm,2.5cm),(4cm,3mm)) ;
endfig;

end.

> Moreover, I have a simple question: Is there any way one could redifine the 
(Continue reading)

Palle Jørgensen | 10 Nov 16:28 2003
Picon

Re: A problem with graph.mp

Martin Buchmann <Martin_Buchmann <at> gmx.net> writes:

> In my opion that makes more sense than calling TeX to get a circle. Or
> is there any problem which i don't see at the moment?

For a circle it is ok; even for me...

The advantage of calling TeX is that one gets easy access to a wide
range of symbols (including letters) that one can use to plot with.

And I think that it is easier when I don't have to define the symbols
myself.

--

-- 
Palle Jørgensen, Stud.scient., BSc

E-post: pallej(at)ifa(dot)au(dot)dk
WWW:    http://www.ifa.au.dk/~pallej/
M Atakan Gurkan | 10 Nov 20:28 2003

metapost limit

Hi,
I am using metapost to plot results of my calculations. I have 
encountered the problem of hitting the capacity limit when I
have too many (~10000) points drawn with the pen:

u:=3cm;
path sq; 
sq := (-4/200u,-4/200u)--(4/200u,-4/200u)--(4/200u,4/200u)--(-4/200u,4/200u)--cycle;
pen pensquare;
pensquare = makepen(sq);

it does not happen with the default pen but I guess it will when I increase
the number of points. So, I have a couple questions:
-- is my assumption correct or am I hitting the limit because of my pen?
is there a way to fix this?
-- is there a way to flush the contents and free the memory of metapost?
i looked in the manual but all I could find was shipout, which completes
the figure. Probably I should have looked in Metafont Book or something,
but I thought maybe there is a common solution.

I know I can increase the memory available to Metapost but I want a more
permanent and portable solution.

thanks a lot,

ato

Gmane