[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Fwd: using grace to plot a straight line........





---------- Forwarded message ----------
From: Antonio Luiz Pacifico <alpacifico@gmail.com>
Date: 2008/6/17
Subject: Re: using grace to plot a straight line........
To: Michael Fothergill <mikef20000@hotmail.com>


Why don't you try R? See: http://www.r-project.org/  For Debian/GNU users: apt-get install r-base r-recommended ... (etc. Just do apt-cache search GNU | grep R)

If I understood well your problem, in R it will be resolved like this (after calling R in any terminal):

x <- c(1,2,3,7,9,11)
y <- c(1,2,3,7,7,7)
plot(x,y)          # or, for example: plot(x,y,type='b')

Now you see the gradient different of zero in the initial region, you could continue in R:
nx <- x[1:3]
ny <- y[1:3]
grad <- lm(ny ~ nx)
A <- grad[[1]][[1]]
B <- grad[[1]][[2]]

Now type B and see your gradient!!!

Well, some explanation:
Plotting x and y you could see the first region of interest (that linear and with some gradient different of zero). Next, the new variables nx and ny are, literally, new x and new y. When you put nx <- [1:3] you told to R that the new x must receive the first 3 terms of the old one. Same for ny. After that, grad receive the output of the already implemented function "lm" that brings you the linear coefficient of the curve (A) and its gradient (B).

Note the lm can do lot more than this... try to type help('lm') on the command line of your R interpreter.

Have fun with R... I think it is one of the best statistical software ever...

Antonio

2008/6/17 Michael Fothergill <mikef20000@hotmail.com>:


Dear Folks,

I have now got grace6 installed and running.

I have been poking around with it and looking at the documentation.

I have a dumb question.

It's supposed to be an XY type plotting program (I think any way).

So, how do you input a set of coordinates into it and plot them?

There are lots of ways of fiddling with the axes and putting labels on things etc but I can't figure out where to put data into it.....

In the data menu there is an import option.  If you click on this then you get a menu that looks as though it might read a data file of some kind.......

Could I create a file in e.g. emacs and put the following coordinates it:

(1,1)
(2,2)
(3,3)
(4,4)
(5,5)

and get it to read it in as coord.dat or something like that?

If you plotted this line it would be a straight line with a gradient of 1 going through the origin in a simple XY 2-D coordinate system.

What is the magic secret to inputting these data points into grace and plotting them?

I also have a more difficult question.

Let's suppose I have a set of coordinates, say ten points in all.  But, in this case they don't produce a straight line when you plot them......

The initial part is  a straight line pretty much, but then the points veer away to the right on a simple XY coordinate system and gradually bend towards a horizontal straight line....


It's rather like starting with the first three points above (1,1), (2,2) and (3,3).  They would be on a straight line with a gradient of 1.  But now lets imagine the next seven points make the gradient fall gradually to zero (straight line).....


The last three points could end up being some thing like (7,7), (9,7) and (11,7).  This should be a straight line which is horizontal (gradient zero) and lives on the y=7 coordinate.

This would be called a rectangular hyperbola by people like Gil Grissom or whatever his name is on CSI.....

What I want to do is collect some data that will form a rectangular hyperbola and plot them in grace and then e.g. print it out and fit by eye a straight line to the first few points near the origin to get the gradient at the start of the curve (the (1,1), (2,2) and (3,3) bit of it).

Smarter than this would be a clever dick software that actually mathematically fit and drew the best fitting straight line through the early part of the hyperbola to get the gradient at the start of the curve......

This is not necessary, but a plot that I could print out and draw the straight line on by hand would be pretty good.

I could figure out the gradient from the XY coordinates on the printed graph pretty easily.

Suggestions welcome on this.

If you think another piece of software might fit the bill other than grace I would appreciate a hint.

Regards

Michael Fothergill












































_________________________________________________________________

http://clk.atdmt.com/UKM/go/msnnkmgl0010000009ukm/direct/01/

--
To UNSUBSCRIBE, email to debian-amd64-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org




Reply to: