Skip to content
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

Formating Node Labels/Titles #71

Open
AkshatSudheshwar opened this issue Feb 27, 2019 · 4 comments
Open

Formating Node Labels/Titles #71

AkshatSudheshwar opened this issue Feb 27, 2019 · 4 comments

Comments

@AkshatSudheshwar
Copy link

AkshatSudheshwar commented Feb 27, 2019

Hi,

I am currently trying to use FloWeaver for mapping waste flows at a macroscopic level:
image

I have to incorporate many more flows in this Sankey and I was hoping to somehow increase the font size of the node labels if that is possible?

Additionally, since some nodes have been created just for the purpose of formatting, is it possible to hide/suppress the node labels without defining the nodes as waypoints (eg: nodes['level2to4_biowaste'] = Waypoint(title=''))?

@AkshatSudheshwar AkshatSudheshwar changed the title Formating Node Labels Formating Node Labels/Titles Feb 27, 2019
@ricklupton
Copy link
Owner

Hi Akshat,

Thanks for getting in touch. floWeaver uses ipysankeywidget to draw the Sankey diagrams, so you can adjust the styling as shown in the examples there (see the bit about CSS in this section).

You could try a cell like this:

%%html
<style>
.sankey .node {
    font-size: 20pt;
}
</style>

Additionally, since some nodes have been created just for the purpose of formatting, is it possible to hide/suppress the node labels without defining the nodes as waypoints (eg: nodes['level2to4_biowaste'] = Waypoint(title=''))?

I'm not sure exactly what you mean here. It should be possible to hide the title by passing title='' to both Waypoints and ProcessGroups. Does that help?

@AkshatSudheshwar
Copy link
Author

AkshatSudheshwar commented Feb 28, 2019

Hi Rick,

Thank you so much for your help with the font size issue.

To hide the node titles, currently I am using the following method:

===================================================================
Level_2 = Partition.Simple('process', [('',['consumer_2']),
'MSW_collection_CHPhigh_2', 'MSW_collection_CHPlow_2',
'MSW_collection_DH_2','MSW_collection_EP_2',
'MSW_collection_PS_2', (' ',['direct_deliveries_tf_2']) ])

nodes = {
'Level2': ProcessGroup(['consumer_2','direct_deliveries_tf_2',
'MSW_collection_CHPhigh_2', 'MSW_collection_CHPlow_2',
'MSW_collection_DH_2','MSW_collection_EP_2',
'MSW_collection_PS_2'])
}

nodes['Level2'].partition = Level_2

===================================================================

For now I am defining groups in the partition.simple with titles as ''; however since the nodes with the same titles are grouped, therefore I will have to add the number of spaces within the title definition (because I wish to keep consumer_2 and direct_deliveries_tf_2 separate in the Sankey, the former is defined as '' whereas the latter as '_'). This is not very suitable because I will have to define titles with a different number of spaces for around 50-60 nodes.

If there is a particular syntax to define the title in the ProcessGroup definition, I would really appreciate your help with the same.

Thank you so much again!

P.S. I saw that it is possible to define the title and style (shown below) but I am could not figure out how to use it within the framework of floweaver.

image

@ricklupton
Copy link
Owner

I see -- no, at the moment there's no way to separate the id of the partition group (which must be unique, hence the multiple spaces) from the title displayed on the Sankey diagram. We should update the Partition code to make this possible.

A workaround might be to use multiple ProcessGroups?

Level_2 = Partition.Simple('process', [('',['consumer_2']),
'MSW_collection_CHPhigh_2', 'MSW_collection_CHPlow_2',
'MSW_collection_DH_2','MSW_collection_EP_2',
'MSW_collection_PS_2', (' ',['direct_deliveries_tf_2']) ])

nodes = {
    'Level2_consumer': ProcessGroup(['consumer_2'], title=''),
    'Level2_direct_deliveries': ProcessGroup(['direct_deliveries_tf_2'], title=''),
    'Level2': ProcessGroup(['MSW_collection_CHPhigh_2', 'MSW_collection_CHPlow_2',
                            'MSW_collection_DH_2','MSW_collection_EP_2',
                            'MSW_collection_PS_2'],
                            partition=Level_2)
}

You would need to replace every

Bundle(..., 'Level2'),

with

Bundle(..., 'Level2_consumer'),
Bundle(..., 'Level2_direct_deliveries'),
Bundle(..., 'Level2'),

and vice versa for the flows leaving Level2.

@AkshatSudheshwar
Copy link
Author

AkshatSudheshwar commented Mar 17, 2019

Yes, I know using multiple ProcessGroups is an option; in fact, that was present code in the originally. However, then the number of bundles will became too large to manage and connect. So we decided to go ahead with the multiple spaces option.

Thank you again for your help though :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants