DingWB / PyComplexHeatmap

PyComplexHeatmap: A Python package to plot complex heatmap (clustermap)
https://dingwb.github.io/PyComplexHeatmap/
MIT License
249 stars 28 forks source link

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

Closed kerenzhou062 closed 8 months ago

kerenzhou062 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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

DingWB commented 8 months ago

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

DingWB commented 8 months ago

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 commented 8 months ago

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

DingWB commented 8 months ago

I see. Thanks for the question.