Comments (10)
That did it! Thank you Rick. I'll msg you if the work get published!
from floweaver.
Hi @owlonewolf, glad you're finding it useful!
Does this example help?
https://floweaver.readthedocs.io/en/latest/tutorials/colour-scales.html#More-customisation
You can define a custom colour scale class with a custom get_color
method, which returns a grey colour if the link value is below some threshold, otherwise returns super().get_color(link, value)
to return the default colour.
from floweaver.
Thanks, mhmm so you suggest changing this line in def get_palette
:
name = 'Greens_9' if link.type == 'Student' else 'Blues_9'
to what exactly? if link.value <= 5
Sorry If I'm missing something basic.
from floweaver.
I added a little example at the end of https://github.com/ricklupton/floweaver/blob/master/docs/tutorials/colour-scales.ipynb
from floweaver.
Thank you for the effort Rick. I'm grateful, but I must admit I still can't get where I want.
Your code works and I can colour flows under a threshold. The issue is that I can't seem to keep my manual palette, which gives one colour pr. source.
Here is the colouring I have, which I'd like to combine with a threshold grey.
Right now, when I apply the threshold function, what I get is (obviously also another dataset and flows)
I've also tried replacing QuantitativeScale with CategoricalScale to no avail.
PS. In the colour-intensity tutorial, what is the idea behind the data structure in the beginning? I might misunderstand something, but the first two columns confuses me because they repeat the same row and therefore seem unnessary.
from floweaver.
I've added another example with a CategoricalScale
. Does that do what you are trying to do?
The source
and target
columns in the data structure are because floweaver is expecting the data to be describing a set of flows between points. In this example, all the flows are in parallel to each other, so it seems redundant. If you work with this kind of data a lot, where the source
and target
are not relevant, I guess there could be a convenient wrapper function which accepted data without these columns and created a simple SankeyDefinition so you could just specify the partitions and other options.
Code additions welcome!
from floweaver.
It does, woohoo! Except it ignores the specified palette, both my custom palette and in your example ('blues9').
Ahh I think I understand now re the columns.
from floweaver.
I ventured into the darkness (source code) and it seems the CategoricalScale and prep_qualitative_palette are where it goes wrong.
It is defaulting to "pastel9" as coded in line 62 of color_scales.py.
I'm beyond my expertise here, but for some reason prep_qualitative_palette doesn't receive the palette input, so whether the palette is specified as a dict or a string doesn't matter, cause it just defaults to none.
from floweaver.
I think I made a mistake in my examples -- the lines that say
super().__init__(attr)
should say
super().__init__(attr, **kwargs)
so that extra options like palette
are passed through.
from floweaver.
As promised, here is a link to the published work see fig 4. Floweaver was used for the main graph (and cited in the supplementary material along with the Extended methods seciton). Thank you for the great package and the support here.
from floweaver.
Related Issues (20)
- Set minimum width for flow HOT 2
- Reversal of source flow causes number of groups to be truncated HOT 1
- Code Example HOT 2
- Define size in SankeyWidget() HOT 4
- Floweaver not importing
- Use floweaver in loop HOT 2
- When converting data to json, "Object of type int64 is not JSON serializable" error occurs HOT 1
- How to extend the length of texts for the target column? HOT 2
- floweaver does not even the basic project sankeys from tutorials
- Node labels HOT 1
- Order of nodes HOT 2
- Is it possible to control the positioning of the labels? HOT 2
- plotting multiple diagrams HOT 1
- Adjusting size of nodes HOT 1
- jupyter-sankey-widget javascript error HOT 2
- Starting new flows from waypoints and preserving order HOT 1
- Use threshold (based on one measure) to choose a (quantitative) colour scheme based on another measure HOT 2
- colour scales tutorial, minor issues
- Define order of flows in a bundle
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from floweaver.