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

Distinguish plot and show for associations parameters #49

Closed
Baukebrenninkmeijer opened this issue May 6, 2020 · 8 comments · Fixed by #50
Closed

Distinguish plot and show for associations parameters #49

Baukebrenninkmeijer opened this issue May 6, 2020 · 8 comments · Fixed by #50
Labels
enhancement New feature or request

Comments

@Baukebrenninkmeijer
Copy link
Contributor

This is more of a suggestion, since I find myself working around it.

Describe the new feature:

Have the option to show the plot (currently done with the plot parameter), but also the option to plot (currently no option). The function associations is very neat, but you don't always want to plot the results, but just get the dataframe. I suggest adding a show parameter.

What is the current outcome?

Currently, there is no way not to plot (i.e. create matplotlib object). This means, when working in a notebook, it will always show the plot at the end of a cell, disregarding the value of the plot parameter.

Is it backward-compatible?

No. show would replace plot in functionality, and plot would get a different meaning.

My current workaround is to create a figure/ax before calling associations, and passing ax to associations. Then I call plt.close(ax) to remove the plot.

@Baukebrenninkmeijer Baukebrenninkmeijer added the enhancement New feature or request label May 6, 2020
@Baukebrenninkmeijer
Copy link
Contributor Author

Btw, if you this or #48 are cool, I can also create a pull request. Let me know what you think.

@shakedzy
Copy link
Owner

shakedzy commented May 6, 2020

Hey @Baukebrenninkmeijer - isn't this already solved in version 0.5.0? The output is now a dict, with the dataframe and plot.
If you only want the dataframe, you can simply do:

df = associations(data, plot=False, ...)['corr']

@Baukebrenninkmeijer
Copy link
Contributor Author

Yes, but the plot doesn't need to be returned unfortunately. The plot is still in the global matplotlib statespace, and thus will be rendered. At least, that was my experience today.

@Baukebrenninkmeijer
Copy link
Contributor Author

I'll see if I can get an example tomorrow.

@shakedzy
Copy link
Owner

shakedzy commented May 7, 2020

I think I understand what you're saying

@Baukebrenninkmeijer
Copy link
Contributor Author

As you can see below, I have set plot=False, but the figure is still rendered. As soon as you instantiate a matplotlib figure, it will show at the end of a cell.

image

It can be fixed fairly simple by setting a parameter that determines whether it will even create a plot, like I suggested above. It would be nice to do it in a backward compatible mode, but that might be a bit confusing if plot keeps referring to showing the plot.

@shakedzy shakedzy linked a pull request May 7, 2020 that will close this issue
@shakedzy
Copy link
Owner

shakedzy commented May 7, 2020

Check this PR: #50
Is this what you asked for?

@Baukebrenninkmeijer
Copy link
Contributor Author

Yes, great work! Also really like the solution :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants