2016-05-23 2 views
1

いくつかの曲線をプロットしています。Imaxと複数の周波数に対してCiclo de servicioです。傍受値を表示する、matplotlib

for Fs in np.linspace(70e3,200e3,4): 
    Vo_sweep = np.linspace(0,1,1000) 
    delta_I = [I_max(Vo) for Vo in Vo_sweep] 
    plt.plot(Vo_sweep,delta_I) 

enter image description here

は方程式が、私は基本的にこれをやって少し複雑ですが、私はネストされた2回の独立変数のためのスイープ、 FsVo

を作ってるんだということを行うには

そして私は特に「ciclo de servicio」が0.71である点に興味があります。私はX軸と各曲線と青い線の傍受のY値に値0.71を表示することができますどのように

+0

これは愚かな質問かもしれませんが、もしあなたのx軸が0から1000までのすべての整数値を持っているなら(何とか0から1.0にプロットする)、 'x = 0.71'のy値ではない' I_max(709) '?次に、その値をグラフに書き込むために注釈(たとえば)を使用することができます。こちらをご覧ください:http://matplotlib.org/users/annotations_intro.html – StefanS

+0

@StefanSに同意します。構築することで、x = 0.71の各関数の値、またはそれに最も近いxを知ることができます。だから、私の提案は、リストにI_max(0.71)を保存し、次に周波数の関数としてI_max(0.71)を示す小さなパネルを下に追加することです。あなたは多くの異なる曲線を持っている場合、これはあなたに簡単に理解できる静かで滑らかな機能を与えます。 – Alejandro

答えて

1

あなたは(何でもあなたの機能や垂直線を任意のデータを使用して、迎撃マーカーをプロットしたい場合交差点を計算することをお勧めします(存在する場所)。数ヶ月前に私はあなたに役立つかもしれない答えを出しました。あなたはそれを確認することができますhere

import numpy as np 
import matplotlib.pyplot as plt 

def line_intersection(line1, line2): 
    xdiff = (line1[0][0] - line1[1][0], line2[0][0] - line2[1][0]) 
    ydiff = (line1[0][1] - line1[1][1], line2[0][1] - line2[1][1]) #Typo was here 

    def det(a, b): 
     return a[0] * b[1] - a[1] * b[0] 

    div = det(xdiff, ydiff) 
    if div == 0: 
     return None 

    d = (det(*line1), det(*line2)) 
    x = det(d, xdiff)/div 
    y = det(d, ydiff)/div 
    return x, y 

def near(a, b, rtol=1e-5, atol=1e-8): 
    return abs(a - b) < (atol + rtol * abs(b)) 
def crosses(line1, line2): 
    """ 
    Return True if line segment line1 intersects line segment line2 and 
    line1 and line2 are not parallel. 
    """ 
    (x1,y1), (x2,y2) = line1 
    (u1,v1), (u2,v2) = line2 
    (a,b), (c,d) = (x2-x1, u1-u2), (y2-y1, v1-v2) 
    e, f = u1-x1, v1-y1 
    denom = float(a*d - b*c) 
    if near(denom, 0): 
     # parallel 
     return False 
    else: 
     t = (e*d - b*f)/denom 
     s = (a*f - e*c)/denom 
     # When 0<=t<=1 and 0<=s<=1 the point of intersection occurs within the 
     # line segments 
     return 0<=t<=1 and 0<=s<=1 


for Fs in np.linspace(70e3,200e3,4): 
    Vo_sweep = np.linspace(0,1,1000) 
    delta_I = [i*Fs*np.log((i+1.1)/10) for i in range(len(Vo_sweep))] #[I_max(Vo) for Vo in Vo_sweep] 
    plt.plot(Vo_sweep,delta_I) 

plt.vlines(0.71,min(delta_I),max(delta_I)) 

for Fs in np.linspace(70e3,200e3,4): 
    x = np.linspace(0,1,1000) 
    y = [i*Fs*np.log((i+1.1)/10) for i in range(len(Vo_sweep))] 
    for i in range(1,len(delta_I)): 
     p1 = np.array([x[i-1],y[i-1]],dtype='float') 
     p2 = np.array([x[i],y[i]],dtype='float') 
     k1 = np.array([0.71,min(delta_I)],dtype='float') 
     k2 = np.array([0.71,max(delta_I)],dtype='float') 
     if crosses((p2,p1),(k1,k2)): 
      seg = line_intersection((p2,p1),(k1,k2)) 
      plt.scatter(seg[0],seg[1],c='red',s=90) 
      print(seg) 

plt.ylim(min(delta_I),max(delta_I)) 
plt.xlim(0,1) 

plt.show() 

、この中で結果:

Plots markers intercepts matplotlib

をこの特定のレシピはまた、それがに興味がある可能性がある場合、座標傍受を印刷している問題に似た解決策を適応さ

あなた:

(0.70999999999999985, 211670610.06954533) 
(0.70999999999999985, 342704797.25546497) 
(0.70999999999999985, 473738984.44138455) 
(0.70999999999999985, 604773171.62730408) 

罪あなたが速い人工合成をしなければならなかったデータを提供しなかったのですが、それはあなたのI_max()関数をdelta_Iの定義に置き換えるのと同じくらい簡単です。