Ask Your Question

How to save combinations of plots?

asked 2019-04-01 00:28:40 +0200

stockh0lm gravatar image

updated 2019-04-01 01:30:52 +0200

I can ceate several plots like this

a = plot(f1, (x,-1,2))
b = plot(f2, (x,-1,2))
c = plot(f3, (x,-1,2))

and merge them with


How can I save the resulting image?


does not work.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-04-01 02:32:44 +0200

dazedANDconfused gravatar image

updated 2019-04-01 14:55:07 +0200

Basically you want to save the picture, not show it. combining show and save is the problem. Try this:

a = plot(f1, (x,-1,2))
b = plot(f2, (x,-1,2))
c = plot(f3, (x,-1,2))
pic = a+b+c'pic.pdf')

Press on the link pic.pdf to see it and download it. Note, with multiple plots you might want to color them. This can be done, for example, with b = plot(f2, (x,-1,2),color='red'). If you want to show as well insert the line right after pic is defined.

EDIT: As Juanjo comments below, you can combine the 3 plots into 1. If you stack the functions together on one line using ; you can compress the code even more:

f1=x; f2=cos(x); f3=x^2
pic = plot([f1,f2,f3], (x,-1,2), color=["red","green", "blue"])'pic.pdf')
edit flag offensive delete link more


You can also combine the graphs with just one plot command:

pic = plot([f1,f2,f3], (x,-1,2), color=["red","green", "blue"])

Juanjo gravatar imageJuanjo ( 2019-04-01 11:07:44 +0200 )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: 2019-04-01 00:28:40 +0200

Seen: 251 times

Last updated: Apr 01 '19