[Question] Graphing with a List
04-30-2017, 03:46 PM (This post was last modified: 04-30-2017 03:50 PM by Freire.)
Post: #1
 Freire Junior Member Posts: 33 Joined: Apr 2017
[Question] Graphing with a List
I want to make a graph like this:
Code:
FOR k FROM 1 TO 500 STEP 2 DO y:=k*0.15; x1:=30+f1(k)*0.15; x2:=30+f2(k)*0.15; ARC_P(G0,x1,220-y,0.1,RGB(0,0,255)); ARC_P(G0,x2,220-y,0.1,RGB(255,0,0)); END;
But it takes a long time to evaluate the functions(the functions do lots of tasks), taking like 30 seconds to finish the plot.
To solve this I tried to make lists with values, then to copy to my program,
But I dont know how to copy the values in an easy way instead of formatting myself.
Does someone has an easy solution for this?
Code:
L1:=MAKELIST(30+f1(k)*0.15,k,1,500,2); L2:=MAKELIST(30+f2(k)*0.15,k,1,500,2); L3:=MAKELIST(k*0.15,k,1,500,2);
04-30-2017, 03:59 PM
Post: #2
 Han Senior Member Posts: 1,882 Joined: Dec 2013
RE: [Question] Graphing with a List
(04-30-2017 03:46 PM)Freire Wrote:  I want to make a graph like this:
Code:
FOR k FROM 1 TO 500 STEP 2 DO y:=k*0.15; x1:=30+f1(k)*0.15; x2:=30+f2(k)*0.15; ARC_P(G0,x1,220-y,0.1,RGB(0,0,255)); ARC_P(G0,x2,220-y,0.1,RGB(255,0,0)); END;
But it takes a long time to evaluate the functions(the functions do lots of tasks), taking like 30 seconds to finish the plot.
To solve this I tried to make lists with values, then to copy to my program,
But I dont know how to copy the values in an easy way instead of formatting myself.
Does someone has an easy solution for this?
Code:
L1:=MAKELIST(30+f1(k)*0.15,k,1,500,2); L2:=MAKELIST(30+f2(k)*0.15,k,1,500,2); L3:=MAKELIST(k*0.15,k,1,500,2);

Given a list, you can access the elements using the function syntax. For example, L1(3) would retrieve the third item from list L1. It also works for local variables created in a program. Unless your data changes frequently, I think you have the fastest approach (i.e. generate the data outside of your program, and have your program simply graph the data).

Would it be possible to share your formula for your functions? Perhaps there could be something in the functions that we could help optimize.

Graph 3D | QPI | SolveSys
04-30-2017, 04:31 PM (This post was last modified: 04-30-2017 04:51 PM by Freire.)
Post: #3
 Freire Junior Member Posts: 33 Joined: Apr 2017
RE: [Question] Graphing with a List
The thing is I have the values in list L1, also the values doesn't change.
But I wanted a list inside my program with all the 250 values of L1 without having to type then manually. I mean, I generated the values to L1 one time, then I get somehow these values and copy then to a variable in my program (L1 copied to a LOCAL listx1). Formating all these values one by one seems the wrong way to do it.

Quote:Would it be possible to share your formula for your functions? Perhaps there could be something in the functions that we could help optimize.

The code is below, and the functions sl_t() and sv_t() come from this post: Steam Table IAPWS-IF97

Code:
  FOR k FROM 1 TO 368 STEP 3 DO   y:=k;   x1:= sl_t(y);   x2:= sv_t(y);     ARC_P(G0,30+(x1*28),(220-y*0.31667),0.1,RGB(0,0,255));     ARC_P(G0,30+(x2*28),(220-y*0.31667),0.1,RGB(255,0,0));   END;   FOR k FROM 1 TO 12 STEP 1 DO   y:=368+k*0.4955;   x1:= sl_t(y);   x2:= sv_t(y);     ARC_P(G0,30+(x1*28),(220-y*0.31667),0.1,RGB(0,0,255));     ARC_P(G0,30+(x2*28),(220-y*0.31667),0.1,RGB(255,0,0));   END;

Plotted graph
05-01-2017, 02:59 AM
Post: #4
 Freire Junior Member Posts: 33 Joined: Apr 2017
RE: [Question] Graphing with a List
I've managed to create the lists without having to evaluate the functions at plot-time.

Solved.
05-01-2017, 11:31 AM
Post: #5
 Giancarlo Member Posts: 266 Joined: Dec 2013
RE: [Question] Graphing with a List
Hello,
This example is very useful about graphing a curve point by point using the graphic commands of the prime (arc_p or whatever).
Is there a way to use the prime plotting features instead of building our own graph?

I mean, if we have a set of points (list,matrix) which is the best way to plot them?

Thanks

Giancarlo
05-01-2017, 03:30 PM (This post was last modified: 05-01-2017 03:30 PM by Freire.)
Post: #6
 Freire Junior Member Posts: 33 Joined: Apr 2017
RE: [Question] Graphing with a List
Example:
You have
L1:= MAKELIST (X,X,1,100,1);
L2:= MAKELIST (X^3,X,1,100,1);
L1 will act as x and L2 will act as y.
Go to App > Statistics 2Var
Go to Symbolic View
Enter the L1 in place of C1 and L2 in place of C2.

Then go to Plot View
Go to Zoom and Autoscale. Done.

PS: The lists get erased after plotting, and at some configurations they can generate strange values.
05-01-2017, 04:26 PM
Post: #7
 Tim Wessman Senior Member Posts: 2,293 Joined: Dec 2013
RE: [Question] Graphing with a List
Hello,

In the meantime, put your data in C1/C2 and you won't have a problem.

TW

Although I work for HP, the views and opinions I post here are my own.
 « Next Oldest | Next Newest »