Ask Your Question

2 questions : savefig + show

asked 2023-01-02 21:02:06 +0100

ErWinz gravatar image

hello here my code that works

for n in range(8):
    dn(x)=diff(f(x), x, n)
        +text("n="+str(n),(0,0.1*factorial(n)),color="green",bounding_box={'boxstyle':'round', 'fc':'w'}))


my questions :

a) how can i automatize the show, can i write. For example :

show(p[i] for in in range(8))

dont give the image but a code that says : <πšπšŽπš—πšŽπš›πšŠπšπš˜πš›Β πš˜πš‹πš“πšŽπšŒπšΒ <πšπšŽπš—πšŽπš‘πš™πš›>Β πšŠπšΒ πŸΆπš‘πŸ·πŸΌπŸΎπš‹πŸ·πšπšπŸ»πŸΆ>

b) i can't find the way to save instead of show

in the help, the formulation is something like but i can't get it, dont understand how to write this type of code with mine ?

thanks :-)

edit retag flag offensive close merge delete

2 Answers

Sort by Β» oldest newest most voted

answered 2023-01-02 22:54:01 +0100

For (a) you can use show(*[p[i] for i in range(8)]).

For (b), one option is to construct a graphics array:

P = graphics_array([p[i] for i in range(8)], 2, 4)  # 2x4 array of the images
edit flag offensive delete link more

answered 2023-01-03 00:32:51 +0100

ErWinz gravatar image

thanks very much it works very weel

so if in understand well : these both codes are equivalent, aren't they ?

show(*[p[i] for i in range(8)])

show(graphics_array([p[i] for i in range(8)], 2, 4))

so that * is a sort of shortcut of graphics_array() ?

for the second :

P = graphics_array([p[i] for i in range(8)], 2, 4)


[Errno 2] No such file or directory: '~/Desktop/toto.png'

i will try to find it out alone


edit flag offensive delete link more


The use of ~ in filenames is a shell thing, and Python doesn't understand it, or at least this function doesn't understand it. Use the full path: /home/username/toto.png or whatever.

John Palmieri gravatar imageJohn Palmieri ( 2023-01-03 05:54:39 +0100 )edit

* is Python syntax. It passes to show not a single argument, which is a list, but instead passes each of that list's entries as the arguments. So show(*[1,2,3]) is equivalent to show(1,2,3).

John Palmieri gravatar imageJohn Palmieri ( 2023-01-03 05:56:46 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2023-01-02 21:02:06 +0100

Seen: 88 times

Last updated: Jan 03 '23