2016-09-14 108 views
-1

我正嘗試在一個密謀圖上繪製多個相關事物。- 更改線條樣式

我想同時區分和關聯這些行。爲了讓自己更清晰,我正在繪製我訓練的分類器的ROC特徵。我想要一種具有相同顏色但不同線條樣式的特定分類器用於訓練方法。

我目前用它來滿足我的要求: enter image description here

下面是相同的代碼,

data = [ 
     go.Scatter(
      mode='lines+markers', 
      x=df_LogisticRegression['FPR'], # assign x as the dataframe column 'x' 
      y=df_LogisticRegression['TPR'], 
      name = "Logistic Regression all attributes", 
      marker=dict(
       color="blue", 
       symbol='square' 
      ), 
     ), 
     # and so on for all other algos 
     go.Scatter(
      mode='lines+markers', 
      x=df_LogisticRegression_nonSP['FPR'], # assign x as the dataframe column 'x' 
      y=df_LogisticRegression_nonSP['TPR'], 
      name = "Logistic Regression non-sparse attributes", 
      marker=dict(
       color="blue", 
       symbol='square-open' 
      ), 
     ), 
     # and so on for all other algos 
    ] 
layout = go.Layout(
    title='ROC Curve', 
    yaxis=dict(title='True Positive Rates(TPR)'), 
    xaxis=dict(title='False Positive Rates(FPR)') 
) 
fig = go.Figure(data=data,layout=layout) 
iplot(fig) 

例如, 我期待有迴歸爲藍色的顏色,但「所有屬性應爲實線,具有」非稀疏屬性「的屬性應爲虛線。

我試圖查閱並讀取文檔在情節上,但找不到任何幫助。

+0

當您在模式中編寫「線條」時,即使點很稀疏,它也會繪製線條。它會加入點。 –

+0

只需嘗試'mode = markers'爲非稀疏數據集 –

+0

我需要一條線,我可以不以任何方式更改線條樣式嗎?我正在看[Plotly shapes](https://plot.ly/python/shapes/)和第一個例子,是否有類似的東西可以實現? –

回答

0

這是因爲情節,繪製基於你要求它做的模式的數據。如果你說mode=markers它將只繪製標記。如果您說mode=lines它將加入數據中的所有點並將其繪製爲線。

請參閱此頁https://plot.ly/python/line-and-scatter/#line-and-scatter-plots瞭解更多可以使用繪圖繪製的線條示例。