Plotting surfaces with holes ?

78 views
Skip to first unread message

Emmanuel Charpentier

unread,
Dec 5, 2015, 3:03:04 PM12/5/15
to sage-support
Plot2d() gracefully handles plotting a fnction undefined (in real terms) on part of the plotting domain. For example :
plot(sqrt(x^2-1),(x,-3/2,3.2))
displays two half-axes of hyperbole, and waons that some points have been lost.

plot3d() seems to lack this facility : an undefined point causes the loss of al the plot.

How would you handle this case ? I want to plot a function defined only for some part of the plotting domain. I do not have an analytic definition for the bounds of this domain (it is defined by an equation with no closed form solution, but easily approximated by find_root()).

Sincerely yours,

--
Emmanuel Charpentier

Emmanuel Charpentier

unread,
Dec 5, 2015, 3:17:22 PM12/5/15
to sage-support
Of course, there is no such thing as plot2d(). Thinko... Please read plot()...

William Stein

unread,
Dec 5, 2015, 4:07:27 PM12/5/15
to sage-support
I would rather answer a concrete and specific question. Please
provide a concrete example you care about.

William

>
> Sincerely yours,
>
> --
> Emmanuel Charpentier
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.



--
William (http://wstein.org)

slelievre

unread,
Dec 9, 2015, 5:48:27 PM12/9/15
to sage-support


2015-12-05 21:03:04 UTC+1, Emmanuel Charpentier:

An illustration:

sage: plot(lambda x: sqrt(x^2 - 1), (-2, 2))
verbose
0 (2716: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 99 points.
verbose
0 (2716: plot.py, generate_plot_points) Last error message: 'math domain error'
Launched png viewer for Graphics object consisting of 2 graphics primitives
sage
: plot3d(lambda x, y: sqrt(x^2 + y^2 - 1), (-2, 2), (-2, 2))
/opt/sage69b1/local/lib/python2.7/site-packages/sage/repl/rich_output/display_manager.py:570: RichReprWarning: Exception in _rich_repr_ while displaying object: math domain error
 
RichReprWarning,
Graphics3d Object


One workaround might be, if your function f sometimes
returns complex output, to plot f(x) when real, and 0 otherwise.

Emmanuel Charpentier

unread,
Dec 11, 2015, 10:23:53 AM12/11/15
to sage-support
Dear William, dear list,

Sorry for this late answer (I've been interrupted by Real Life (TM)...).

Le samedi 5 décembre 2015 22:07:27 UTC+1, William a écrit :

[ Snip... ]


I would rather answer a concrete and specific question.  Please
provide a concrete example you care about.

I created a Jupyter worksheet (attached) exhibiting the problem I want to solve. It runs on Sage 6.10beta6 but not, as far as I know, on the version of Sage running on the Sagemath cloud (it uses enhancements that the recent Sympy update brings).

[ BTW : it is a real-life problem : I was wondering about the properties and the validity of a very "natural" transformation of parameters in Bayesian analysis. ]

--
Emmanuel Charpentier

A (not so minimal) example.ipynb.gz

Emmanuel Charpentier

unread,
Dec 11, 2015, 10:27:54 AM12/11/15
to sage-support
I did thought of that.

The problem is to determine in advance the right pseudo-value to use  in order not to squash the z values of interest and not to obscure the view of the surface(s) of interest (plot3d does not have, alas, xmin, ymin zmin, xmax, ymax, zmax parameters...).

Sincerely,

--
Emmanuel Charpentier
Reply all
Reply to author
Forward
0 new messages