plotting a surface defined in a domail

33 views
Skip to first unread message

Francesco

unread,
Mar 9, 2018, 6:24:50 AM3/9/18
to sage-support
How can i plotting a function of two variables defined in a domain different from a square ?
I need, for example, to plot a f(x,y) where x is between 0 and 1, and y is between 0 and x ( it is a triangle )
Can you help me?

Emmanuel Charpentier

unread,
Mar 11, 2018, 3:39:51 AM3/11/18
to sage-support
A couple of ideas :
  • Parametric plot3d, using a convenient transformation of the parameters
  • implicit_plot3d
  • list_plot3d
Also, it might help to note that in a 3D plot, points returned as float("NA") do not plot ; however, this is undocumented and I still do not know how this is obtained. Given the changes currently undergoing in the graphics functions, you might want to use this only as a last-resort measure...

--
Emmanuel Charpentier

slelievre

unread,
Mar 11, 2018, 12:05:39 PM3/11/18
to sage-support
Building on Emmanuel Charpentier's tips, here is an example.

    sage: x_range = (0, 1)
    sage: y_range = (0, 1)
    sage: in_domain = lambda x, y: 0 < y < x < 1
    sage: def f(x, y):
    ....:     if in_domain(x, y):
    ....:         return x^2 + y^2
    ....:     return float('nan')
    ....: 
    sage: plot3d(f, x_range, y_range)
    sage: plot3d(f, x_range, y_range, viewer="threejs")

Francesco

unread,
Mar 14, 2018, 9:22:44 AM3/14/18
to sage-support

thank you Charpentier and Slelievre;
I have an other question: the command


plot3d(f, x_range, y_range, viewer="threejs")

doesn't plot the surface but only the edges of a box . How can i install this viewer ?

slelievre

unread,
Mar 14, 2018, 9:29:25 AM3/14/18
to sage-support
Wed 2018-03-14 13:22:44 UTC, Francesco:


> I have an other question: the command
> plot3d(f, x_range, y_range, viewer="threejs")
> doesn't plot the surface but only the edges of a box. How can i install this viewer?

What version of Sage are you using?
How did you define f?
Reply all
Reply to author
Forward
0 new messages