I am using contour plot but I am facing the issue that it is plotting the points where the function is undefined. For example, I am using a rational function and it has a discontinuity in y = 1(red horizontal line.
Is there any way to avoid this?
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,1.3,500)
y = np.linspace(0,2.5,500)
X, Y = np.meshgrid (x, y)
plt.contour(X, Y, R(X, Y), , colors=‘r’)
Contouring assumes your data is continuous, it has no way of knowing what you intend between grid points. If you
[-12.02984218 -33.69646609 52.9702432 15.82742857]
R values go from negative to positive as they cross
y=1 and hence a contour line is drawn for
In this example you can get away with specifying one of your
y points being exactly at 1 using
y = 1.0
and hence your calculated
R is infinite and a contour line is not drawn. But this is not generally reliable as you are at the mercy of finite floating-point precision.
Thank you so much for your answer!