Python: How to Show a Plot
05-09-2021, 06:29 PM
Post: #1
 Eddie W. Shore Senior Member Posts: 1,448 Joined: Dec 2013
Python: How to Show a Plot
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
05-09-2021, 08:28 PM
Post: #2
 ace Junior Member Posts: 5 Joined: May 2021
RE: Python: How to Show a Plot
(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])
05-09-2021, 09:21 PM
Post: #3
 Eddie W. Shore Senior Member Posts: 1,448 Joined: Dec 2013
RE: Python: How to Show a Plot
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.
05-09-2021, 11:43 PM
Post: #4
 rprosperi Super Moderator Posts: 5,661 Joined: Dec 2013
RE: Python: How to Show a Plot
(05-09-2021 09:21 PM)Eddie W. Shore Wrote:  [code]
import matplotl import *
import hpprime import *

...

Should be "from matplotl import *", right?

--Bob Prosperi
05-09-2021, 11:43 PM
Post: #5
 tcab Member Posts: 188 Joined: Dec 2017
RE: Python: How to Show a Plot
(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.
05-10-2021, 05:35 AM
Post: #6
 ace Junior Member Posts: 5 Joined: May 2021
RE: Python: How to Show a Plot
(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.
05-10-2021, 05:50 PM
Post: #7
 roadrunner Senior Member Posts: 429 Joined: Jun 2015
RE: Python: How to Show a Plot
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:

05-10-2021, 07:00 PM
Post: #8
 toml_12953 Senior Member Posts: 1,981 Joined: Dec 2013
RE: Python: How to Show a Plot
(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.

Tom L
Cui bono?
05-10-2021, 07:34 PM
Post: #9
 robmio Member Posts: 165 Joined: Jan 2020
RE: Python: How to Show a Plot
maybe the new firmware needs a good revision. we hope for the future
 « Next Oldest | Next Newest »

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