benmaier / netwulf

Interactive visualization of networks based on Ulf Aslak's d3 web app.
MIT License
293 stars 26 forks source link

color difference between canvas and download/reproduction #28

Closed benmaier closed 4 years ago

benmaier commented 5 years ago

So here's a weird one: While playing around with colors and reproducibility, I've noticed that my matplotlib-figures looked brighter than what I've seen on the screen. And apparently that's true, even though the downloaded figure has the right colors again:

network_bug

funnily enough, the grey node stroke did not change between display in the browser and matplotlib/downloaded png. Ideas what's happening here?

benmaier commented 5 years ago

paging @ulfaslak for some time later

benmaier commented 5 years ago

oh, and the background color is also plain white in all of them

benmaier commented 5 years ago

code for reproduction

import numpy as np
from netwulf import visualize
import networkx as nx

G = nx.barabasi_albert_graph(5,1)

config = {
    # Input/output
    'zoom':4,
    # Physics
    'node_charge': -70,
    'node_gravity': 0.5,
    'link_distance': 15,
    'link_distance_variation': 2,
    'node_collision': True,
    'wiggle_nodes': False,
    'freeze_nodes': False,
    # Nodes
    'node_fill_color': '#79aa00',
    'node_stroke_color': '#898989',
    'node_label_color': '#888',

    'display_node_labels': True,
    'scale_node_size_by_strength': True,
    'node_size': 5,
    'node_stroke_width': 1,
    'node_size_unevenness': 0.5,
    # Links
    'link_color': '#758000',
    'link_width': 11,
    'link_alpha': 0.2,
    'link_width_unevenness': 0.5,
    # Thresholding
    'display_singleton_nodes': True,
    'min_link_weight_percentile': 0,
    'max_link_weight_percentile': 100
}

stylized_network, new_config = visualize(G,config=config)

import pprint
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(stylized_network)

from netwulf import draw_netwulf
import matplotlib.pyplot as pl

fig, ax = draw_netwulf(stylized_network)
pl.show()
ulfaslak commented 5 years ago

Pretty sure I'm not colorblind, but I actually can't tell the difference :O