question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

plotting time-series data over a network

See original GitHub issue

Hi @marcomusy

I am trying to plot time series data related to nodes of a graph

import networkx as nx
from vedo import *

G = nx.gnm_random_graph(n=10, m=15, seed=1)
nxpos = nx.spring_layout(G)
nxpts = [nxpos[pt] for pt in sorted(nxpos)]

nx_lines = []
for i, j in G.edges():
    p1 = nxpos[i].tolist() + [0]  # add z-coord
    p2 = nxpos[j].tolist() + [0]
    nx_lines.append([p1, p2])

nx_pts = Points(nxpts, r=12)
nx_edg = Lines(nx_lines).lw(2)

# node values
values = [[100, .80, .10, .79, .70, .60, .75, .78, .65, .90],[1, .80, .10, .79, .70, .60, .75, .78, .65, .10],[1000, .30, .10, .79, .70, .60, .75, .78, .65, .90]]
time = [0, 0.1, 0.2] # in seconds
for val,t in zip(values, time):
    nx_pts.pointColors(val, cmap='YlGn', vmin=min(val), vmax=max(val)).addScalarBar()
    show(nx_pts, nx_edg, nx_pts.labels('id'), interactive=True, bg='black', title=f'{t} seconds')

I intend to create multiple frames with time stamp displayed in each frame. I couldn’t achieve this using the above code. Suggestions on how to visualize the data over time will be highly appreciated.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
DeepaMahmcommented, Aug 3, 2020

Please check if by chance pycharm installed vtk9.0.1 instead of vtk8.1.2, because that might be causing issues.

I’ve checked the version and it’s vtk8.1.2. I could see the correct images in the interactive mode, the problem is while the images are saved. first 2 images are black

EDIT: I’ve installed vtk9.0.1 now and finally, I’m able to view the correct images.

1reaction
marcomusycommented, Jul 26, 2020

Hi, try the following:

import networkx as nx
from vedo import *

G = nx.gnm_random_graph(n=10, m=15, seed=1)
nxpos = nx.spring_layout(G)

nxpts = [nxpos[pt] for pt in sorted(nxpos)]
nx_lines = [ (nxpts[i], nxpts[j]) for i, j in G.edges() ]

nx_pts = Points(nxpts, r=12)
nx_edg = Lines(nx_lines).lw(2)

# node values
values = [[1, .80, .10, .79, .70, .60, .75, .78, .65, .90],
          [3, .80, .10, .79, .70, .60, .75, .78, .65, .10],
          [1, .30, .10, .79, .70, .60, .75, .78, .65, .90]]
time = [0.0, 0.1, 0.2] # in seconds
for val,t in zip(values, time):
    nx_pts.cmap('YlGn', val, vmin=0.1, vmax=3)
    if t==0:
        nx_pts.addScalarBar()
 
    # make a plot title
    x0, x1 = nx_pts.xbounds()
    y0, y1 = nx_pts.ybounds()
    t = Text('My μ-Graph at time='+str(t)+' seconds',
             font='BPmonoItalics', justify='center', s=.07, c='lb')
    t.pos((x0+x1)/2, y1*1.4)
    show(nx_pts, nx_edg, nx_pts.labels('id',c='w'), t,
         interactive=True, bg='black')

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 types of plots that will help you with time series analysis
A time plot is basically a line plot showing the evolution of the time series over time. We can use it as the...
Read more >
The Complete Guide to Time Series Data - Clarify.io
Scatter plots are usually used as a way to visualize random variables in time series data.
Read more >
Time Series Data Visualization with Python
In this tutorial, you will discover 6 different types of plots that you can use to visualize time series data with Python.
Read more >
From time series to complex networks: The visibility graph
In this article we present a tool in time series analysis: the visibility graph. This algorithm maps a time series into a network....
Read more >
How to visualize time series data - InfoWorld
Visualizing time series data can help detect patterns, outliers that defy those patterns, whether the data is stationary or non-stationary, and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found