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

Unexpected behaviour of figsize and overlap #53

Closed
W-L opened this issue Apr 23, 2020 · 6 comments
Closed

Unexpected behaviour of figsize and overlap #53

W-L opened this issue Apr 23, 2020 · 6 comments

Comments

@W-L
Copy link

W-L commented Apr 23, 2020

Hi @Sbebo,
Thanks very much for the fantastic module. I encountered a strange behaviour when trying to control figsize and overlap, which I assume is a bug. Here's a minimum code example:

# load modules and create a list of random data
import numpy as np
import joypy as jp

dist_list = []
for i in range(20):
    dist_list.append(np.random.normal(loc=np.random.random(), size=100))

With these arguments the plot is created normally:

fig, ax = jp.joyplot(dist_list, overlap=1, figsize=(8,3.3))
fig.show()

image

But for any height value of figsize that is higher than 3.3 in this case, all density plots appear extremely flattened, and changing the overlap has no effect at all:

fig, ax = jp.joyplot(dist_list, overlap=1, figsize=(8,3.4))
fig.show()

image

I noticed this when working on some larger data, and the "threshold" of this sudden change was at a different value for the height of figsize
Is there a way to have a larger figure but prevent this from happening?
Thanks!

@leotac
Copy link
Owner

leotac commented Apr 23, 2020

Hi there, thanks for using joypy!
This is interesting, I'll try to take a look.

@leotac
Copy link
Owner

leotac commented Apr 29, 2020

It looks like I can't reproduce it, using your example I'm able to print even with figsize (8,30) and everything works as expected.
Could you include your environment? (the output of pip list or conda list would be enough)

@W-L
Copy link
Author

W-L commented Apr 29, 2020

Thanks for taking a look. I just tried it on the command line and in IPython and indeed it works fine. It seems like this is a problem within PyCharm instead, despite using the same environment. Sorry about that..

@W-L W-L closed this as completed Apr 29, 2020
@leotac
Copy link
Owner

leotac commented Apr 29, 2020

No worries!
Interesting but I wouldn't know how to help you there.

@nitrocalcite
Copy link

This seems to be an issue specifically with PyCharm's SciView. For future users, you can work around this by going to "File > Settings > Python Scientific" in PyCharm and unchecking "Show plots in tool window". matplotlib plots will then appear natively, and everything seems to work fine.

Incidentally, I can confirm this issue on the latest version of PyCharm without explicitly setting figsize. My basic plot command is

joyplot(data, labels=labels, overlap=10, kind="values", x_range=list(range(n)))

No matter the value of overlap, the figure is generated as if overlap=0. Negative values of overlap still throw errors.

Thanks for the heads-up! I never would have thought to try this.

@W-L
Copy link
Author

W-L commented May 7, 2020

There is another possible workaround in case you do not want to deactivate SciView completely. If you are using IPython within PyCharm you can use its magic commands to switch to a different plotting backend. E.g. executing %matplotlib qt in the python console will also prompt plots to appear in a separate tool window (rendered correctly w.r.t this issue). Then simply restarting the console will make it revert to default behaviour of showing plots in SciView. Here's a link to the docs about it: ipython magic commands for matplotlib

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

No branches or pull requests

3 participants