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.

setting title and color bar, directed graph

See original GitHub issue

Hi @marcomusy

This is a follow up to my question on SO. I’d like to ask for clarification on the following,

  1. I’d like to know how to assign symbols in title of a scalarbar. Latex formatting doesn’t work e.g. nx_pts.pointColors(vals, cmap='YlGn', vmin=min(vals), vmax=max(vals)).addScalarBar(title='$\mu$')

  2. How can we set titles for plot? I tried, show(nx_pts, nx_edg, nx_pts.labels('id'), interactive=True, bg='black', title='plot') this doesn’t display the title.

  3. Is it possible to create discontinuous color bars? For example, while trying to assign the following set of values that contains an outlier vals = [100, .80, .10, .79, .70, .60, .75, .78, .65, .90] all entries, except 100, are assigned the same color.

Please find the complete code below,

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
vals = [100, .80, .10, .79, .70, .60, .75, .78, .65, .90]
nx_pts.pointColors(vals, cmap='YlGn', vmin=min(vals), vmax=max(vals)).addScalarBar(title='$\mu$')
show(nx_pts, nx_edg, nx_pts.labels('id'), interactive=True, bg='black', title='plot')

  1. How to convert the above graph, G, to a directed graph? From the suggestion offered on SO, I could use g = DirectedGraph(layout=‘fast2d’)

I am not sure how to add edges ed_ls = [(0, 6), (0, 7), (0, 5), (8, 0), (0, 4), (1, 4), (1, 7), (1, 9), (2, 9), (3, 6), (3, 4), (8, 3), (3, 5), (3, 7), (6, 9)] for each item in ed_ls, e.g. (0,6) the edge is directed from 0 to 6. Thanks a lot

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:38 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
FedeClaudicommented, Oct 12, 2020

Works on windows!

1reaction
DeepaMahmcommented, Oct 13, 2020

@marcomusy The update works! And the interpolation looks great!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to put a title on a colorbar? - MATLAB Answers
Using the handle for the colorbar (in your case, the variable hcb), you can locate the colorbar handle title using the get function....
Read more >
Undesired colorbar and axis labels/plot titles interaction
I try to produce colormaps by combining LinearSegmentedColormap in combination with Imshow, using matplotlib library, and I'm having a hard time ...
Read more >
Matplotlib.pyplot.title() in Python - GeeksforGeeks
The title() method in matplotlib module is used to specify title of ... a bar graph and display its title using matplotlib.pyplot.title() ....
Read more >
Title positioning — Matplotlib 3.6.2 documentation
Title positioning# ... Matplotlib can display plot titles centered, flush with the left side of a set of axes, and flush with the...
Read more >
Label Bars - NCL Graphics
lb_1.ncl: Demonstrates a default color bar. ... A title can be added to the label bar by setting lbTitleOn equal to True, 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