Giter Site home page Giter Site logo

Comments (10)

owoodhansen avatar owoodhansen commented on June 11, 2024 1

That did it! Thank you Rick. I'll msg you if the work get published!

from floweaver.

ricklupton avatar ricklupton commented on June 11, 2024

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.

owoodhansen avatar owoodhansen commented on June 11, 2024

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.

ricklupton avatar ricklupton commented on June 11, 2024

I added a little example at the end of https://github.com/ricklupton/floweaver/blob/master/docs/tutorials/colour-scales.ipynb

from floweaver.

owoodhansen avatar owoodhansen commented on June 11, 2024

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.
CDR

Right now, when I apply the threshold function, what I get is (obviously also another dataset and flows)
wrong

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.

ricklupton avatar ricklupton commented on June 11, 2024

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.

owoodhansen avatar owoodhansen commented on June 11, 2024

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.

owoodhansen avatar owoodhansen commented on June 11, 2024

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.

ricklupton avatar ricklupton commented on June 11, 2024

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.

owoodhansen avatar owoodhansen commented on June 11, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.