I would like to plot and rotate with the mouse a 3D SimpleGraph
from LightGraphs.jl
. Here is MWE:
using LightGraphs
using GraphRecipes
import Plots
Plots.PlotlyBackend()
function plotGraph()
graph = SimpleGraph(20, 100)
nb_nodes = nv(graph)
xx = rand(nb_nodes)
yy = rand(nb_nodes)
zz = rand(nb_nodes)
p = graphplot(graph, x=xx, y=yy, z=zz)
end
Plots.pyplot()
Plots.plotly()p = plotGraph()
I see the plotly
widgets, but I cannot rotate the plot. When I hover the mouse over the nodes, I only see the x,y
coordinates of the nodes, leading me to believe that the z
coordinate is ignored.
To make sure I was using plotly
properly, I tried the following example, which allowed me to rotate in 3D. What am I missing? Thanks.
import Plots
Plots.PlotlyBackend()
n = 100
ts = range(0, stop = 8π, length = n)
x = ts .* map(cos, ts)
y = (0.1ts) .* map(sin, ts)
z = 1:n
Plots.plot(x, y, z, zcolor = reverse(z), m = (10, 0.8, :blues, Plots.stroke(0)), leg = false, cbar = true, w = 5)
Plots.plot!(zeros(n), zeros(n), 1:n, w = 10)
Never mind. I forgot to add an argument dim=3
in graphplot
. The graph now rotates nicely in 3D! False alarm.There is still an issue. See next post.