2014-12-23 8 views
2

커브를 (아마도 3D로) 어떻게 진행될 것인지를 보여줄 수있는 것으로 그려 볼 수 있습니다. 예를 들어, 원형 평면 커브가 시계 방향 또는 시계 반대 방향으로 진행 중임을 나타냅니다.방향이있는 등고선/곡선

여기에 같은 곡선, http://mathworld.wolfram.com/CauchyIntegralFormula.html

지금은 대등 한 기능이 있더라도 확실하지 않다, 그래서 당신을 보여주는 예를 들어이 없습니다. 읽어 주셔서 감사합니다.

편집 : 이것에 대해 꽤 많이 검색합니다. gnuplot에서도이 작업을 수행 할 수 있다고 생각하지 마십시오.

+0

가능한 중복 [화살표하기 matplotlib 곡선 틱 (HTTP : //stackoverflow.com/questions/26911898/matplotlib-curve-with-arrow-ticks) – Schorsch

+0

다른 하나는이 애플리케이션에 대해 몇 가지 변경 사항이 필요합니다. 이것은 일반적으로 매개 변수 곡선에 적용됩니다. 여기에 관심을 가져 주셔서 감사합니다. – user3856487

답변

1

흥미로운 질문입니다. 내가 지금 여기에 우리가 (자유롭게 MPL의 코드에서 영감을 streamplot) 가서, 신속하고 더러운 해킹 이상 시간이 없다

import matplotlib.lines as mlines 
import matplotlib.patches as mpatches 
import matplotlib.pyplot as plt 
import numpy as np 

def add_arrow_to_line2D(
    axes, line, arrow_locs=[0.2, 0.4, 0.6, 0.8], 
    arrowstyle='-|>', arrowsize=1, transform=None): 
    """ 
    Add arrows to a matplotlib.lines.Line2D at selected locations. 

    Parameters: 
    ----------- 
    axes: 
    line: list of 1 Line2D obbject as returned by plot command 
    arrow_locs: list of locations where to insert arrows, % of total length 
    arrowstyle: style of the arrow 
    arrowsize: size of the arrow 
    transform: a matplotlib transform instance, default to data coordinates 

    Returns: 
    -------- 
    arrows: list of arrows 
    """ 
    if (not(isinstance(line, list)) or not(isinstance(line[0], 
              mlines.Line2D))): 
     raise ValueError("expected a matplotlib.lines.Line2D object") 
    x, y = line[0].get_xdata(), line[0].get_ydata() 

    arrow_kw = dict(arrowstyle=arrowstyle, mutation_scale=10 * arrowsize) 
    if transform is None: 
     transform = axes.transData 

    arrows = [] 
    for loc in arrow_locs: 
     s = np.cumsum(np.sqrt(np.diff(x) ** 2 + np.diff(y) ** 2)) 
     n = np.searchsorted(s, s[-1] * loc) 
     arrow_tail = (x[n], y[n]) 
     arrow_head = (np.mean(x[n:n + 2]), np.mean(y[n:n + 2])) 
     p = mpatches.FancyArrowPatch(
      arrow_tail, arrow_head, transform=transform, 
      **arrow_kw) 
     axes.add_patch(p) 
     arrows.append(p) 
    return arrows 


fig, ax = plt.subplots(1, 1) 
t = np.linspace(0., 4*np.pi, 100.) 
line = ax.plot(np.log(t+1)*np.cos(t), np.log(t+1)*np.sin(t),"-") 
add_arrow_to_line2D(ax, line, arrow_locs=[0.1, 0.2, 0.3, 0.4, 0.6, 0.8, 0.99], 
        arrowsize=1.5) 

ax.axis("equal") 
ax.set_xlim([-4., 4.]) 
ax.set_ylim([-4., 4.]) 
plt.show() 

enter image description here

+0

코드를 보내 주셔서 감사합니다. 효과가 있습니다. – user3856487