Khi vẽ đồ thị với một gián đoạn/asymptote/singularity/bất cứ điều gì, là có bất kỳ cách tự động để ngăn chặn Matplotlib từ 'tham gia các dấu chấm' trên 'break'? (vui lòng xem mã/hình ảnh bên dưới).
Tôi đọc rằng Sage có một cơ sở [detect_poles] trông đẹp, nhưng tôi thực sự muốn nó hoạt động với Matplotlib.làm thế nào để xử lý một asymptote/gián đoạn với Matplotlib
import matplotlib.pyplot as plt
import numpy as np
from sympy import sympify, lambdify
from sympy.abc import x
fig = plt.figure(1)
ax = fig.add_subplot(111)
# set up axis
ax.spines['left'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('zero')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
# setup x and y ranges and precision
xx = np.arange(-0.5,5.5,0.01)
# draw my curve
myfunction=sympify(1/(x-2))
mylambdifiedfunction=lambdify(x,myfunction,'numpy')
ax.plot(xx, mylambdifiedfunction(xx),zorder=100,linewidth=3,color='red')
#set bounds
ax.set_xbound(-1,6)
ax.set_ybound(-4,4)
plt.show()
Cảm ơn bạn đã này câu hỏi; mặc dù bạn đã gắn thẻ nó là 'python', hãy lưu ý rằng nó thường là câu hỏi' matplotlib'; Tôi đã sử dụng bản thân mình một trong những câu trả lời từ Julia chứ không phải là Python. Trân trọng. –