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

How to control the size of the heatmap section to make more space for the legends section? #100

Open
muzier9 opened this issue Nov 21, 2024 · 16 comments

Comments

@muzier9
Copy link

muzier9 commented Nov 21, 2024

image
Whether it is a single heatmap or a double heatmap, sometimes the space of legends does not fully display all the legends content.

I've also noticed this in the PyComplexHeatmap document example.
image

@DingWB
Copy link
Owner

DingWB commented Nov 21, 2024

Thanks for reporting this. It has already been fixed.
Please re-install from github.

Please also let me know whether it works or not.

@muzier9
Copy link
Author

muzier9 commented Nov 21, 2024

No, there's no change. It can't work.

@DingWB
Copy link
Owner

DingWB commented Nov 21, 2024

It works on my side.
You need to uninstall and install again from github:
pip uninstall -y PyComplexHeatmap && pip install git+https://github.com/DingWB/PyComplexHeatmap

@DingWB
Copy link
Owner

DingWB commented Nov 22, 2024

Hi @muzier9 ,

In default, if there is only one column of legend, the legend width will be estimated automatically, but if there is more than 1 column of legend (because the figure height is too small), the estimated legend width may not be correct.

So, there are two solutions:
(1). Increase the height of figsize, then the legend width will be calculated automatically.
(2). If you don't want to increase the height, you can increase legend_width to assign more space for the legend.

Please test both of the above two methods and let me know the result.

@muzier9
Copy link
Author

muzier9 commented Nov 22, 2024

If legends had only one column, it would show up very well. If there are many legends in two columns, it will still be incomplete. I tried to set the legend_width, but it doesn't seem to work. Why?

This is the automatic legend width :
Collecting annotation legends..
Collecting annotation legends..
Estimated legend width: 35.102777777777774 mm
Display as shown :
image

Then I set the legend_width :
cm_ax, legend_axes = composite(cmlist=cmlist, main=0, legend_hpad=2, legend_y=0.88, legend_gap=10, col_gap=0.1, With width_ratios=[1, 1.2], legend_width=40),

I should have expanded the legend_width to 40, but The image hasn't changed at all.

@DingWB
Copy link
Owner

DingWB commented Nov 22, 2024

Can you share your code and data with me? @muzier9
You can also send me simulated data so that I can reproduce this issue and fix it.

@DingWB
Copy link
Owner

DingWB commented Nov 22, 2024

I test with this example data, and it works (https://dingwb.github.io/PyComplexHeatmap/build/html/notebooks/composite_heatmaps.html)

Here is the result
image

Can you try a larger legend_width? Such as 60 or 100?

@muzier9
Copy link
Author

muzier9 commented Nov 22, 2024

I have sent the code and test data to you by email. Can you check it? I changed the legend_width and it didn't work.

@muzier9
Copy link
Author

muzier9 commented Nov 22, 2024

I know what the problem is. The ide I used before is Pycharm, I changed it to the one you use Jupyter and tried it again, and it can be successfully modified. But I want to use Pycharm for window display graphics, do you have any good ideas?

@DingWB
Copy link
Owner

DingWB commented Nov 22, 2024

It is working. Nothing wrong with the code.

image

@DingWB
Copy link
Owner

DingWB commented Nov 22, 2024

I know what the problem is. The ide I used before is Pycharm, I changed it to the one you use Jupyter and tried it again, and it can be successfully modified. But I want to use Pycharm for window display graphics, do you have any good ideas?

Just save it to pdf and the PDF should be fine

plt.savefig("test.pdf", bbox_inches='tight')
plt.show()

@muzier9
Copy link
Author

muzier9 commented Nov 22, 2024

Yes! The saved pdf displays very well. I also wonder if there is any way to make the window display complete like pdf?

@DingWB
Copy link
Owner

DingWB commented Nov 22, 2024

No idea. You can explore it or search for it on Google about the pycharm.

@muzier9
Copy link
Author

muzier9 commented Nov 22, 2024

Thank you very much. These are very useful to me.

@DingWB
Copy link
Owner

DingWB commented Nov 22, 2024

I just released a new version (1.8.1); you can install it using pip
Please help me test it; if you find any issues, please report them.

@muzier9
Copy link
Author

muzier9 commented Nov 22, 2024

OK. I will use the new version.

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

2 participants