Wie kann ich einem Streudiagramm in Plotly eine einzelne Zeile hinzufügen?Python

Python-Programme
Anonymous
 Wie kann ich einem Streudiagramm in Plotly eine einzelne Zeile hinzufügen?

Post by Anonymous »

Betrachten Sie das folgende MWE, um ein Streudiagramm unter Verwendung der Python -API zum Diagramm zu zeichnen: < /p>

import plotly.plotly as py
import plotly.graph_objs
import plotly.offline
plotly.offline.init_notebook_mode()

data = list(range(10))
trace = plotly.graph_objs.Scatter(
x=list(range(len(data))),
y=data
)
plotly.offline.iplot([trace])
< /code>

< /p>
Was, wenn ich jetzt eine (Say) Horizontal -Line -Line -Line -Linie -Zeile hinzufügen möchte. Diagramme, aber keines der Beispiele scheinen abzudecken, wie man verschiedene Diagramme überlagert oder einfach gerade Linien und ähnliche Formen zeichnet. < /p>

Ein naiver Ansatz, um dies zu tunimport plotly.plotly as py
import plotly.graph_objs
import plotly.offline
plotly.offline.init_notebook_mode()

data = list(range(10))
trace = plotly.graph_objs.Scatter(
x=list(range(len(data))),
y=data
)
trace_line = plotly.graph_objs.Scatter(
x=list(range(len(data))),
y=[4] * len(data),
mode='lines'
)
plotly.offline.iplot([trace, trace_line])
< /code>

< /p>

Ansatz scheint mich zu suboptimal zu sein. Der Tooltip auf der Mausschwebede. < /p>

Gibt es einen besseren Ansatz, um dies zu erreichen?>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post