-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to set node width #91
Comments
you can create a column with the size of node, upload the table: cytoscape.table.loadTableData(<dataframe>, df_key=<df_key>, table_key_column=< table_key_column >) and then use that to define NODE_SIZE: NODE_SIZE=cytoscape.vizmap.mapVisualProperty(visualProperty="NODE_SIZE",\
mappingType="passthrough",\
mappingColumn="word_size")
cytoscape.vizmap.update_style("dataStyle",mappings=[NODE_SIZE]) |
Is If it is, I get an Here are some alternate instructions that worked for me, assuming that the labels for the nodes are already in the node table for your network. #imports
from py2cytoscape.data.cyrest_client import CyRestClient
import pandas as pd
cy = CyRestClient()
#load some data
data = pd.read_csv('../data/<your_data_file.csv>')
#initialize the network
net = cy.network.create_from_dataframe(data,name="<network_name>",collection="<network_collection>")
# get the node table
node_table = net.get_node_table()
# get the label lengths
node_table['size'] = node_table.<label_column>.apply(len)
# update the node table
net.update_node_table(df=table,network_key_col="SUID",data_key_col="SUID")
# choose your favorite default style or skip if you already have a style object
my_style = cy.style.create('Marquee')
# create a mapping from the column value to NODE_SIZE and apply the style
my_style.create_passthrough_mapping(column='size',vp='NODE_SIZE',
col_type='Integer')
cy.style.apply(my_style, net) This is more verbose than the above, but in the above answer it's not really clear (at least to me) what the |
Hello,
how can I resize the nodes of a graph depending on the length of their labels?
I.e., a node with a "long" label should be wider than a node with a "short" label.
Thank you very much for your help -- and for this great library!
Best regads
mtill
Cytoscape:3.7.1
Java:1.8
The text was updated successfully, but these errors were encountered: