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

[ENH] OWColor: Saving and loading color schemata #4977

Merged
merged 5 commits into from
Sep 18, 2020

Conversation

janezd
Copy link
Contributor

@janezd janezd commented Sep 9, 2020

Issue

Resolves #4890.

Description of changes

I defined two file formats. One contains all changes done by the user, e.g.

{
    "categorical": {
        "gender": {
            "renamed_values": {
                "female": "women",
                "male": "man"
            }
        },
        "fasting blood sugar > 120": {
            "rename": "fasting blood sugar is high",
            "colors": {
                "0": "#21FF06",
                "1": "#996633"
            }
        },
        "exerc ind ang": {
            "colors": {
                "0": "#46BEFA",
                "1": "#996633"
            }
        },
        "slope peak exc ST": {
            "renamed_values": {},
            "colors": {
                "upsloping": "#FD8008",
                "flat": "#ED462F",
                "downsloping": "#AAF22B"
            }
        }
    },
    "numeric": {
        "rest SBP": {
            "colors": "linear_bgyw_20_98_c66"
        },
        "cholesterol": {
            "colors": "diverging_bwr_40_95_c42"
        },
    }
}

When loading the file, it's content does not have to exactly match the domain: redundant variables/values are ignored, and data for variables that does not appear in the file is retained as it is in the widget.

The second format contains general definitions of colors, like

{
    "female": "#FF0000",
    "1": "#996633",
    "upsloping": "#FD8008"
}

When saving, it stores the colors for values that were changed by the user, and only if the change if the same for all variables in the domain (e.g. if all "female" that are changed are changed to the same color). When loading, it changes colors for all values that appear in any variable.

Includes
  • Code changes
  • Tests
  • Documentation

@janezd janezd changed the title [ENH] OWColor: Saving and loading color schemata [RFC] [ENH] OWColor: Saving and loading color schemata Sep 9, 2020
@codecov
Copy link

codecov bot commented Sep 9, 2020

Codecov Report

Merging #4977 into master will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #4977      +/-   ##
==========================================
+ Coverage   84.47%   84.51%   +0.03%     
==========================================
  Files         283      283              
  Lines       58344    58471     +127     
==========================================
+ Hits        49289    49414     +125     
- Misses       9055     9057       +2     

@janezd
Copy link
Contributor Author

janezd commented Sep 11, 2020

Note to self: remove the "general" format (in a separate commit, so we still have the code in case we need it someday).

The remaining code implements what the issue was about. The second format is not very useful, except as a workaround for copying colors assigned to one variable to all other variables. A better solution for this is to add "Copy to all" to discrete variables, but so far nobody needed it, so we won' t implement the feature, until somebody wants it badly enough.

@janezd janezd force-pushed the owcolor-save-schemata branch 2 times, most recently from d870181 to 2c67772 Compare September 11, 2020 13:11
@CLAassistant
Copy link

CLAassistant commented Sep 11, 2020

CLA assistant check
All committers have signed the CLA.

@janezd janezd changed the title [RFC] [ENH] OWColor: Saving and loading color schemata [ENH] OWColor: Saving and loading color schemata Sep 11, 2020
@janezd janezd marked this pull request as ready for review September 12, 2020 09:34
@ajdapretnar ajdapretnar self-assigned this Sep 18, 2020
@ajdapretnar
Copy link
Contributor

I tried testing this but I can't seem to get a working file. I tried the first file in the first comment. What am I doing wrong?

@janezd
Copy link
Contributor Author

janezd commented Sep 18, 2020

I may have changed the format (though I think I haven't). But why would you use the file from the comment? You can just change some colors and names, and save the file.

@ajdapretnar ajdapretnar merged commit 690a402 into biolab:master Sep 18, 2020
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

Successfully merging this pull request may close these issues.

Loading pre-defined colour schemes
3 participants