Post Reply 
Python: How to Show a Plot
05-09-2021, 06:29 PM
Post: #1
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
Visit this user's website Find all posts by this user
Quote this message in a reply
05-09-2021, 08:28 PM
Post: #2
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])
Find all posts by this user
Quote this message in a reply
05-09-2021, 09:21 PM
Post: #3
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.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-09-2021, 11:43 PM
Post: #4
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
Find all posts by this user
Quote this message in a reply
05-09-2021, 11:43 PM
Post: #5
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.
Find all posts by this user
Quote this message in a reply
05-10-2021, 05:35 AM
Post: #6
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.
Find all posts by this user
Quote this message in a reply
05-10-2021, 05:50 PM
Post: #7
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:

   

-road
Find all posts by this user
Quote this message in a reply
05-10-2021, 07:00 PM
Post: #8
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?
Find all posts by this user
Quote this message in a reply
05-10-2021, 07:34 PM
Post: #9
RE: Python: How to Show a Plot
maybe the new firmware needs a good revision. we hope for the future
Find all posts by this user
Quote this message in a reply
Post Reply 




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