Post Reply 
Plot Values from a List Gen. by Program
01-14-2015, 07:28 AM
Post: #1
Plot Values from a List Gen. by Program
Hello,

I'm new to this forum and new to the HP Prime.
I bought it in spite of all the criticism and must say that it works perfect for me. (latest firmware)
It's my first programmable calculator and I think it offers a large range of features.
Of course in comparision to matlab and mathcad there is still a way to go ;-), but for a portable device with such a long working duration on a battery its very nice.
I personaly use it in engineering and for making quick estimations in discussions.
So if i'm being asked I can type in the question and can reply it's 42 ;-)

Ok, now for my simple question:
If I make a program, which depends for example on a lookup-table like a list L0.
Is it possible to plot the result, perhaps written to vector/list L1 to the plot screen including the x an y scale?
Or is there a better approach?
Find all posts by this user
Quote this message in a reply
01-14-2015, 10:44 AM (This post was last modified: 01-14-2015 02:25 PM by Snorre.)
Post: #2
RE: Plot Values from a List Gen. by Program
Hello hof,

(01-14-2015 07:28 AM)hof Wrote:  [...]
Ok, now for my simple question:
If I make a program, which depends for example on a lookup-table like a list L0.
Is it possible to plot the result, perhaps written to vector/list L1 to the plot screen including the x an y scale?
[...]
yes it is.
My basic approach for plotting L0 vs L1 would utilize the "Statistics 2Var"-App and look like:
Code:
BEGIN
  // ...
  STARTAPP("Statistics 2Var");  // Set current app.
  C1:=L0; C2:=L1;    // Copy lists to app data columns.
  SetIndep(S1,C1);   // Dataset 1 is column 1 ...
  SetDepend(S1,C2);  // ... vs column 2.
  Fit:=1;  // Turn fit plot off, since we're interested in the data points only.
  STARTVIEW(9);      // Show autoscaled plot.
END;

Greetings
Find all posts by this user
Quote this message in a reply
01-14-2015, 09:56 PM
Post: #3
RE: Plot Values from a List Gen. by Program
Hello Snorre,

thanks, it works fine and partly solves the problem.

I actually thought of a graphics output like in excel where x and y axis are visible with numbers.
But as a first step its okay ;-)
Find all posts by this user
Quote this message in a reply
01-14-2015, 10:32 PM
Post: #4
RE: Plot Values from a List Gen. by Program
Here is a code fragment you might like to review. It might serve as a building block for your own specific needs. (It's just a quick framework, not a complete charting program). The layout allows space to accommodate soft keys (Drawmenu) below, if you wanted to include it. X and Y pixels are equal for this example.

Code:

EXPORT XYChart()
BEGIN
LOCAL t,x;

RECT();                                // Clear figure

LINE_P(51,4,51,214,RGB(128,128,128));                 // v spine:  from 4 to 214 pixels, 210 pixels long
LINE_P(51,109,261,109,RGB(128,128,128));            // h spine:  from 51 to, 261 pixels,  210 pixels wide
TEXTOUT_P("Your Data",263,105,1,RGB(128,128,128));  
          
for t from 4 to 214 step 210/10 do                           // V subticks,  4 pixels wide             
  LINE_P(49,t,53,t,RGB(128,128,128));              
  TEXTOUT_P((-t+109)/105,30,t-4,1,RGB(128,128,128));  // Annotate V-Axis
end;

x:=1;
for t from 51 to 261 step 210/10 do                    // H subticks. 4 pixels wide
  LINE_P(t,107,t,111,RGB(128,128,128));
  x:=NOT(x);
  if x then TEXTOUT_P((t-156)/105,t-4,113,1,RGB(128,128,128)); end;    // Annotate H-Axis  
end;                                                                                                  // H subticks

FREEZE;

RETURN; 
END;

Good luck!

-Dale-
Find all posts by this user
Quote this message in a reply
01-14-2015, 11:21 PM (This post was last modified: 01-15-2015 12:11 AM by Snorre.)
Post: #5
RE: Plot Values from a List Gen. by Program
Hello hof,

you can also set the plot window to show axis labels and numbers (only the current view limits per axis) by .
For more sophisticated graphing you should implement it by yourself as suggested by DrD, but that will be a tremendous task if you want to all the features of the builtin plot function (zooming, panning, tracing etc.).

It may be easier to define a VIEW function within an existing app which TEXTOUTs the numbers onto your current plot.
A skeleton might look like (but leaves much room for improvements):
Code:
VIEW "Show tick labels" ShowTickLabels()
BEGIN
  LOCAL d:=PX→C(C→PX(0,0)+4),
        x:=Xmin - Xmin MOD Xtick,
        y:=Ymin - Ymin MOD Ytick;
  WHILE x<Xmax DO
    TEXTOUT(x,x,d(2),1);
    x:=x+Xtick;
  END;
  WHILE y<Ymax DO
    TEXTOUT(y,d(1),y,1);
    y:=y+Ytick;
  END; 
END;

Greetings
Find all posts by this user
Quote this message in a reply
01-16-2015, 09:10 AM
Post: #6
RE: Plot Values from a List Gen. by Program
Thanks to you both for your nice work, I will try your suggestions in the next time.
My original thought was that this is an integrated feature of the calculator which would be very helpful.
I believe this should have been integrated in the first place and have been of a higher priority to the designers.
But at least it seems to be feasable in some way ;-), although its a bit disappointing.
Thanks again.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)