2017-10-11 17 views
1

私はCSVからデータを取り込み、データをプロットしています。私は一連のデジタル信号をプロットしており、状態が変わったときにポイントをつけています。 Current Digital Plotsplotをサブプロットに追加python

私はいくつかのプロットにいくつかのテキストマーカーを追加しようとしています。これと同様に: Goal Digital Plots

は、ここで私が今持っているコードです:私はtrace2変数を試してみました

points = {'A':[X_SoC[8][1], Y_SoC[8][1]], 'B': [X_SoC[9][1], Y_SoC[9][1]], 'C' :[X_SoC[9][2], Y_SoC[9][2]], 
     'D' : [X_SoC[1][1], Y_SoC[1][1]], 'E': [X_SoC[10][1], Y_SoC[10][1]], 'F' :[X_SoC[10][2], Y_SoC[10][2]], 
     'G' : [X_SoC[11][1], Y_SoC[11][1]], 'H': [X_SoC[10][3], Y_SoC[10][3]], 'J' :[X_SoC[9][3], Y_SoC[9][3]], 
     'K' : [X_SoC[10][4], Y_SoC[10][4]], 'L': [X_SoC[8][2], Y_SoC[8][2]], 'M' :[X_SoC[7][4], Y_SoC[7][4]], 
     'N' : [X_SoC[9][4], Y_SoC[9][4]], 'P': [X_SoC[7][5], Y_SoC[7][5]]} 


pt_A = X_SoC[8][1] 
pt_B = X_SoC[9][1] 
pt_C = X_SoC[9][2] 
pt_D = X_SoC[1][1] 
pt_E = X_SoC[10][1] 
pt_F = X_SoC[10][2] 
pt_G = X_SoC[11][1] 
pt_H = X_SoC[10][3] 
pt_J = X_SoC[9][3] 
pt_K = X_SoC[10][4] 
pt_L = X_SoC[8][2] 
pt_M = X_SoC[7][4] 
pt_N = X_SoC[9][4] 
pt_P = X_SoC[7][5] 



for i in range(Num_Channels): 
    trace0.append(go.Scatter(x=df_lab["Time"], y = df_lab[Headers[i+1]], mode = 'lines', name = Headers[i+1])) 
    trace1.append(go.Scatter(x=X_SoC[i], y = Y_SoC[i], mode = 'markers', = 
False)) 

trace1.append(go.Scatter(x = X_SoC[8][1], y = Y_SoC[8][1], mode = 
'markers+text', text = 'A', textposition = 'bottom')) 

print("The label 'A' should be at ", X_SoC[8][1], " and ", Y_SoC[8][1], " of the ninth graph down") 
fig = tools.make_subplots(rows = Num_Channels, cols = 1,shared_xaxes = True) 

for i in range(Num_Channels): 
    fig.append_trace(trace0[i],i+1,1) 
    fig.append_trace(trace1[i],i+1,1) 

#fig.append_trace(trace2, 9, 1) 

fig['layout'].update(height = 750, width = 950, title = 'Bit Timing!') 
py.iplot(fig) 

、この最新のアプローチは、現在のポイントのプロットを追加することですが、それは表示されませんどのような形や形であってもよい。私の目標は、辞書を試してみることです。ループするだけです。

3番目のプロットを追加するにはどうすればよいですか?

おかげ

答えて

1

まあ、私が思うに、プログラム的に、それはかなり醜いです。しかし、それは私が探しているものです。私がこれまでに終わっているのはここです:

points = {'A':[X_SoC[8][1], Y_SoC[8][1]], 'B': [X_SoC[9][1], Y_SoC[9][1]], 'C' :[X_SoC[9][2], Y_SoC[9][2]], 
     'D' : [X_SoC[1][1], Y_SoC[1][1]], 'E': [X_SoC[10][1], Y_SoC[10][1]], 'F' :[X_SoC[10][2], Y_SoC[10][2]], 
     'G' : [X_SoC[11][1], Y_SoC[11][1]], 'H': [X_SoC[10][3], Y_SoC[10][3]], 'J' :[X_SoC[9][3], Y_SoC[9][3]], 
     'K' : [X_SoC[10][4], Y_SoC[10][4]], 'L': [X_SoC[8][2], Y_SoC[8][2]], 'M' :[X_SoC[7][4], Y_SoC[7][4]], 
     'N' : [X_SoC[9][4], Y_SoC[9][4]], 'P': [X_SoC[7][5], Y_SoC[7][5]]} 

for i in range(Num_Channels): 
    trace0.append(go.Scatter(x=df_lab["Time"], y = df_lab[Headers[i+1]], mode = 'lines', name = Headers[i+1])) 
    trace1.append(go.Scatter(x=X_SoC[i], y = Y_SoC[i], mode = 'markers', showlegend = False)) 

traceA = go.Scatter(x = [points['A'][0]], y = [points['A'][1]], mode = 'markers+text', text = ['A'], textposition = 'left', showlegend = False) 
traceB = go.Scatter(x = [points['B'][0]], y = [points['B'][1]], mode = 'markers+text', text = ['B'], textposition = 'left', showlegend = False) 
traceC = go.Scatter(x = [points['C'][0]], y = [points['C'][1]], mode = 'markers+text', text = ['C'], textposition = 'left', showlegend = False) 
traceD = go.Scatter(x = [points['D'][0]], y = [points['D'][1]], mode = 'markers+text', text = ['D'], textposition = 'left', showlegend = False) 
traceE = go.Scatter(x = [points['E'][0]], y = [points['E'][1]], mode = 'markers+text', text = ['E'], textposition = 'left', showlegend = False) 
traceF = go.Scatter(x = [points['F'][0]], y = [points['F'][1]], mode = 'markers+text', text = ['F'], textposition = 'left', showlegend = False) 
traceG = go.Scatter(x = [points['G'][0]], y = [points['G'][1]], mode = 'markers+text', text = ['G'], textposition = 'left', showlegend = False) 
traceH = go.Scatter(x = [points['H'][0]], y = [points['H'][1]], mode = 'markers+text', text = ['H'], textposition = 'left', showlegend = False) 
traceJ = go.Scatter(x = [points['J'][0]], y = [points['J'][1]], mode = 'markers+text', text = ['J'], textposition = 'left', showlegend = False) 
traceK = go.Scatter(x = [points['K'][0]], y = [points['K'][1]], mode = 'markers+text', text = ['K'], textposition = 'left', showlegend = False) 
traceL = go.Scatter(x = [points['L'][0]], y = [points['L'][1]], mode = 'markers+text', text = ['L'], textposition = 'left', showlegend = False) 
traceM = go.Scatter(x = [points['M'][0]], y = [points['M'][1]], mode = 'markers+text', text = ['M'], textposition = 'left', showlegend = False) 
traceN = go.Scatter(x = [points['N'][0]], y = [points['N'][1]], mode = 'markers+text', text = ['N'], textposition = 'left', showlegend = False) 
traceP = go.Scatter(x = [points['P'][0]], y = [points['P'][1]], mode = 'markers+text', text = ['P'], textposition = 'left', showlegend = False) 

print(points.keys()) 
print("The label 'A' should be at ", points['A'][0] , " and ", points['A'][1] , " of the ninth graph down") 
#print(trace1[8]) 
#print(trace2) 

fig = tools.make_subplots(rows = Num_Channels, cols = 1,shared_xaxes = True) 

for i in range(Num_Channels): 
    fig.append_trace(trace0[i],i+1,1) 
    fig.append_trace(trace1[i],i+1,1) 

fig.append_trace(traceA, 9, 1) 
fig.append_trace(traceB, 10, 1) 
fig.append_trace(traceC, 10, 1) 
fig.append_trace(traceD, 2, 1) 
fig.append_trace(traceE, 11, 1) 
fig.append_trace(traceF, 11, 1) 
fig.append_trace(traceG, 12, 1) 
fig.append_trace(traceH, 11, 1) 
fig.append_trace(traceJ, 10, 1) 
fig.append_trace(traceK, 11, 1) 
fig.append_trace(traceL, 9, 1) 
fig.append_trace(traceM, 8, 1) 
fig.append_trace(traceN, 10, 1) 
fig.append_trace(traceP, 8, 1) 


fig['layout'].update(height = 750, width = 950, title = 'Bit Timing!') 
py.iplot(fig) 

私は間違いなくそれを改善するためにアイデアを開いています。

ありがとうございました

関連する問題