| 1 | initial version |
The issue with contour_plot(check(x, y), (x, -1., 8.), (y, -1., 8.)) arises because check is a Python function, not a symbolic function: Sage first applies the function check to the pair of symbolic variables (x,y), which always returns -1. (because any of the tests of the type x>... returns False for the generic symbolic variable x). The constant output -1. is then passed to the function contour_plot, which explains the uniformly black figure.
To perform a contour plot of h(x, y, 0, 1), where h is a Python function with 4 arguments, use a Python lambda function to transform it into a function of two arguments:
contour_plot(lambda x, y: h(x,y,0,1), (-1.,8.), (1.,8.))
For more details, see the section Symbolic functions versus Python functions of the notebook 2-dimensional plots of functions with SageMath.
| 2 | No.2 Revision |
The issue with contour_plot(check(x, y), (x, -1., 8.), (y, -1., 8.)) arises because check is a Python function, not a symbolic function: Sage first applies the function check to the pair of symbolic variables (x,y), which always returns -1. (because any of the tests of the type x>... returns False for the generic symbolic variable x). The constant output -1. is then passed to the function contour_plot, which explains the uniformly black figure.
To perform a contour plot of h(x, y, 0, 1), where h is a Python function with 4 arguments, use a Python lambda function to transform it into a function of two arguments:
contour_plot(lambda x, y: h(x,y,0,1), h(x, y, 0, 1), (-1.,8.), (1.,8.))
For more details, see the section Symbolic functions versus Python functions of the notebook 2-dimensional plots of functions with SageMath.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.