Skip to content

generate_xticklabels converts all entries to strings, which fails for numeric columns #13

@meson800

Description

@meson800

Currently, generate_xticklabels implicitly converts numerical column labels to text, due to the tick formatting in this line

        dict_labels = dict_labels_by_xticklabel[item.get_text()]

Then, lookup fails due to a type mismatch.

For example, if you have a metadata dataframe:

metadata_df = pd.DataFrame({
  "plasmid": [210, 212, 213],
  "promoter": ["EF1a", "EFS", "PGK"]
})

where the plasmid column was used as an xticklabel, generate_xticklabels will fail because it can't find the string "210" when it looks it up.

I'm not sure what the best way to solve it is. One could be to just copy the dataframe and do a .map(lambda x: str(x)) to convert everything in that lookup column to a string, but it's not guaranteed for non-integers how the axis is labeled. For example, doing str(0.00005) might return "0.00005", but maybe seaborn represents that as "5e-5". Maybe look and see how a categorical seaborn plot converts non-text entries to string xticklabels? We could then just use an internal function if they have it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions