2017-08-08 5 views

Antwort

1

könnten Sie Plotly die Verwendung annotations ohne Text.

enter image description here

import plotly 
import numpy as np 

plotly.offline.init_notebook_mode() 
N = 1000 

data = [plotly.graph_objs.Scatter(x=np.random.randn(N), 
            y=np.random.randn(N), 
            mode = 'markers' 
           ) 
     ] 

xstart = -2 
xmax = 3.5 
xmin = -3.5 
padding = 0.05 
ypos = -0.1 

layout = plotly.graph_objs.Layout(
    xaxis=dict(range=[xmin, xmax]), 
    showlegend=False, 
    annotations=[ 
     dict(
      x=xmin, 
      y=ypos, 
      ax=xstart + padding, 
      ay=ypos, 
      xref='x', 
      axref='x', 
      yref='paper', 
      ayref='paper', 
      showarrow=True, 
      arrowhead=2, 
      arrowsize=1, 
      arrowwidth=3, 
      arrowcolor='#0000ff', 
     ), 
     dict(
      x=xmax, 
      y=ypos, 
      ax=xstart - padding, 
      ay=ypos, 
      xref='x', 
      axref='x', 
      yref='paper', 
      ayref='paper', 
      showarrow=True, 
      arrowhead=2, 
      arrowsize=1, 
      arrowwidth=3, 
      arrowcolor='#ff0000', 
     ) 
    ]) 

plotly.offline.iplot(plotly.graph_objs.Figure(data=data, 
               layout=layout)) 
+0

Wissen Sie, wie die Anmerkung auf 3D zu tun? Ich habe kein Problem, Ihr Ergebnis auf 2D zu reproduzieren, aber wenn ich versuche, auf ein 3D-Diagramm anzuwenden, folgt die Anmerkung nicht dem Diagramm (oder Knoten) nach der Drehung. – user2149631

+0

@ user2149631: Ich denke scatter3d verhalten sich anders mit Anmerkungen. Siehe: https://plot.ly/javascript/text-and-annotations/#3d-annotations –

+0

Danke, Maximilian! Ist es möglich, den Pfeil außerhalb des Zeichenbereichs für 3D zu platzieren? Ich habe versucht, so etwas wie: p = Layout (p, Szene = list ( Anmerkungen = Liste (Liste ( x = 0,3, y = -0,1, z = -0,1, text = "12345", textangle = 0, ax = 0, Ay = -75, xref = 'x', axref = 'x', Yref = paper, ayref = paper, zref = paper, arrowcolor = "schwarz", pfeilgröße = 3, pfeilbreite = 1, pfeilspitze = 1 )) ) ). Aber es funktioniert nicht. – user2149631