HP Forums
Python: How to Show a Plot - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Python: How to Show a Plot (/thread-16905.html)



Python: How to Show a Plot - Eddie W. Shore - 05-09-2021 06:29 PM

This is what I have so far:

Code:
from matplol import *
# scatter plot
axis((0,0,10,10))
grid(True)
plot(1,1)
xlist=[1,2,3,4,5]
ylist=[7,8,9,8,7]
show()

Nothing is shown.

Software Version 5/5/2021 (2.1.14588) - Hardware Version D


RE: Python: How to Show a Plot - ace - 05-09-2021 08:28 PM

(05-09-2021 06:29 PM)Eddie W. Shore Wrote:  This is what I have so far:

Code:
from matplol import *
# scatter plot
axis((0,0,10,10))
grid(True)
plot(1,1)
xlist=[1,2,3,4,5]
ylist=[7,8,9,8,7]
show()

Nothing is shown.

Software Version 5/5/2021 (2.1.14588) - Hardware Version D

Hi Eddie, a couple of things:
  • matplotl is misspelled in your code
  • from your code, the only thing I see plotted is a point plot(1,1), are you trying to plot xlist and ylist?
  • it seems grid and axis are not yet working--also, I believe the syntax for axis is axis([0, 10, 0, 10])



RE: Python: How to Show a Plot - Eddie W. Shore - 05-09-2021 09:21 PM

Code:

import matplotl import *
import hpprime import *

axis([0,0,10,10])
grid(True)
plot(1,1)
xlist=[1,2,3,4,5]
ylist=[7,8,9,8,7]
scatter(xlist,ylist)
eval("wait()")

Still nothing is showing. I can get plots with graphic module fine though.


RE: Python: How to Show a Plot - rprosperi - 05-09-2021 11:43 PM

(05-09-2021 09:21 PM)Eddie W. Shore Wrote:  [code]
import matplotl import *
import hpprime import *

...

Should be "from matplotl import *", right?


RE: Python: How to Show a Plot - tcab - 05-09-2021 11:43 PM

(05-09-2021 09:21 PM)Eddie W. Shore Wrote:  
Code:

import matplotl import *
import hpprime import *
...

Official Python syntax says this should be
Code:

from matplotl import *
from hpprime import *

but yeah, I get nothing displayed either - using the HP Prime Virtual Calculator beta.


RE: Python: How to Show a Plot - ace - 05-10-2021 05:35 AM

(05-09-2021 09:21 PM)Eddie W. Shore Wrote:  
Code:

import matplotl import *
import hpprime import *

axis([0,0,10,10])
grid(True)
plot(1,1)
xlist=[1,2,3,4,5]
ylist=[7,8,9,8,7]
scatter(xlist,ylist)
eval("wait()")

Still nothing is showing. I can get plots with graphic module fine though.

The scatter and scatterplot commands do not work for me. The commands plot and hist do.

Below is a code you can try using plot:

Code:

from matplotl import *

xlist=[1,2,3,4,5]
ylist=[7,8,9,8,7]
plot(xlist,ylist)

For reference, I have the HP Prime G2.


RE: Python: How to Show a Plot - roadrunner - 05-10-2021 05:50 PM

I don't have the beta installed so i can't try it, but wouldn't you need something like:

from matplotl import * as plt

and then

plt.grid(True)
plt.plot(xlist,ylist)
...etc?

similar to this:

[attachment=9461]

-road


RE: Python: How to Show a Plot - toml_12953 - 05-10-2021 07:00 PM

(05-10-2021 05:50 PM)roadrunner Wrote:  I don't have the beta installed so i can't try it, but wouldn't you need something like:

from matplotl import * as plt

and then

plt.grid(True)
plt.plot(xlist,ylist)
...etc?

In Python on other machines, if you leave off the "as plt" clause, you don't need the qualifier plt in front of the function names.


RE: Python: How to Show a Plot - robmio - 05-10-2021 07:34 PM

maybe the new firmware needs a good revision. we hope for the future