pygraphistry icon indicating copy to clipboard operation
pygraphistry copied to clipboard

Question, how to show only somes labels?

Open SalvatoreRa opened this issue 2 years ago • 4 comments

I plotted a graph with graphistry, I want to then take stamp (a static image for a presentation) and I want to higlight only some nodes (the idea to show the labels only of these nodes, the maroon specifically). so showing the labels I want to take a pic and use as an image on the presentation.

the network is quite small less than 100 nodes, I have two dataframe, nodes (where there is the nodes name and my variable of interest diff, which has just two category 0 and 1) and edges (which is a dataframe with two columns from and to, representing the connections between the two nodes)

I am using python

g = graphistry.edges(edges, "from", "to")

g = (g.nodes(nodes, "node_name").encode_point_color(
    "diff", categorical_mapping={1: "silver", 0: "maroon"}))

what I see is a really nice graph, but it showing by default the labels of some nodes (arbitrary choseen).

how I can decide the list of nodes labels has to be showed (without hoovering or clicking on it). is it a way?

SalvatoreRa avatar Dec 07 '21 10:12 SalvatoreRa

Hi @SalvatoreRa !

Currently:

  • we try to sample the screen to ensure an even spread of labels
  • the nodes are prioritized (approximately) by which are biggest
  • we pick 5-10 by default, and you can raise that count

It's reasonable to want to be more specific, so we've been thinking of a couple extensions (API + in-tool).

If we implemented the following, would it work?

.labels(
  #Optional: only sample from nodes where some field has one of a few specific values
  subset_by_key_values={'field': 'type', 'values': ['account', 'id', ...]},

  #Optional: only sample from nodes by explicit node id
  subset_by_ids=['abc', 'def'] 
)

That would be combined with setting # of labels to a large number, guaranteeing all are shown, and only the ones you desire

lmeyerov avatar Dec 08 '21 00:12 lmeyerov

Thanks for the answer,

if I understood it is still not implemented?

SalvatoreRa avatar Dec 08 '21 08:12 SalvatoreRa

Yes - we're still thinking it through & prioritizing, hence the question :)

Would the design ^^^ solve it, or maybe you're thinking something else?

lmeyerov avatar Dec 08 '21 19:12 lmeyerov

I guess so, I think useful in many context. the possible to highlight only some labels (I know many people in research would be interested, to maybe generate pic publication ready where the labels can be highlighted).

SalvatoreRa avatar Dec 08 '21 19:12 SalvatoreRa