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

Try to save results from ClusterMapPlotter as pdf, but the heatmap is a figure not in vector #56

Closed
kerenzhou062 opened this issue Oct 19, 2023 · 6 comments

Comments

@kerenzhou062
Copy link

Try to save results from ClusterMapPlotter as pdf, but the heatmap is a figure not in vector.

`plt.figure(figsize=(6, 30))
cm = ClusterMapPlotter(data=data.loc[:,df_col.index.tolist()],
top_annotation=col_ha,show_rownames=True,
row_cluster=True,col_cluster=False,
label='on/off',legend_gap=7,
cmap='Purples',rasterized=True)

plt.savefig(root + "test.pdf")
plt.show()
`

@DingWB
Copy link
Owner

DingWB commented Oct 19, 2023

Did you set

plt.rcParams['font.family']='sans serif'
plt.rcParams['font.sans-serif']='Arial'
plt.rcParams['pdf.fonttype']=42

and use

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

to save the figure?

If not, please do so and follow by any example on the documentation website, for example: https://dingwb.github.io/PyComplexHeatmap/build/html/notebooks/composite_heatmaps.html#Composite-two-heatmaps-horizontally-for-mouse-DNA-methylation-array-dataset

@kerenzhou062
Copy link
Author

No, it doesn't work. I mean the text part is editable, but the heatmap part is an image.

@DingWB
Copy link
Owner

DingWB commented Oct 19, 2023

Oh, I see.
Please use rasterized=False, then the pdf should be editable.

@DingWB
Copy link
Owner

DingWB commented Oct 19, 2023

However, when your data is enormous and set rasterized=False, the size of the generated pdf would be very large.

Could you please tell me why you would like to edit the pdf? If you want to composite two heatmaps together, you can try the composite function in PyComplexHeatmap. If you would like to draw a custom box or something, you can also do that in PyComplexHeatmap.

@kerenzhou062
Copy link
Author

Thanks, it works now. Well, you always need to adjust the figures to fit different arrangements when get it published.

@DingWB
Copy link
Owner

DingWB commented Oct 19, 2023

I see. Thanks for the question.

@DingWB DingWB closed this as completed Oct 19, 2023
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