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

Introduce orientation to bar plot #94

Merged
merged 3 commits into from Jul 3, 2021

Conversation

sbrugman
Copy link
Contributor

The dendrogram has an option to change the orientation from top-down to left-right. This is convenient when having a large amount of columns. The bar plot misses this option. To make the bar plot effective for large numbers of columns, it should have a similar behaviour.

This pull requests adds the basic functionality. The figsize is not yet adjusted, this should be added.

Introduce orientation to bar plot.
@ResidentMario
Copy link
Owner

Thanks for contributing this PR! This looks like a good start.

There are still a couple of things missing from the re-oriented msno.bar view. To demonstrate, here's the standard orientation for msno.dendrogram:

import numpy as np
import pandas as pd

np.random.seed(42)
simple_df = pd.DataFrame((np.random.random((20, 10)) > 0.5), columns=range(0, 10)).replace(False, np.nan)
large_df = pd.DataFrame((np.random.random((250, 60)) > 0.5)).replace(False, np.nan)

import missingno as msno
import matplotlib.pyplot as plt

msno.dendrogram(simple_df)

temp

And the reoriented view (msno.dendrogram(large_df)):

temp

Here is the standard view for msno.bar (msno.bar(simple_df)):

temp

And the reoriented view added in this PR (msno.bar(large_df)):

temp

The reoriented msno.dendrogram preserves certain features of the plot that the reoriented msno.bar does not preserve. Namely:

  • It chooses a "smart" figure size based on the number of columns in the input data that ensures there is adequate room for the labels; msno.bar does not do that in this PR (as you mentioned in your opening comment).
  • It preserves the axis labels—specifically, the standard values formerly on the y-axis that are now on the x-axis. The reoriented msno.bar only preserves the column labels, all of the other labels are dropped.

If you fix these two issues, I'd be happy to merge this PR. This looks like a great feature!

* Figure size is based on the orientations
* axis-labels are fixed
@sbrugman
Copy link
Contributor Author

Should be fixed.

@ResidentMario
Copy link
Owner

The sizes of the tick labels are inconsistent under rotation.

Default:

download

Rotated:

download

Compare this with what dendrogram does:

download

dendrogram doesn't use fontsize directly, and instead manipulates it using labelsize=int(fontsize / 16 * 20). This may be appropriate to do in this case as well.

Fix for already-existing axis and figsize similar to dendrogram
@sbrugman
Copy link
Contributor Author

Font size problem still requires some tinkering, but we are getting there.

@ResidentMario
Copy link
Owner

@sbrugman Hey, any update on this?

@sbrugman
Copy link
Contributor Author

My focus is somewhere else right now, not sure if I have time soon to fix the font size.

@ResidentMario
Copy link
Owner

ResidentMario commented Sep 11, 2019 via email

@ResidentMario
Copy link
Owner

For whatever reason I can't replicate the font size behavior now. Looks fine, so I'll just merge this as is.

I imagine you don't often submit PRs that take two years to merge. 😉

@ResidentMario ResidentMario merged commit 6ad031d into ResidentMario:master Jul 3, 2021
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.

None yet

2 participants