pinellolab/dictys

Help with saving figures

JasonOSS opened this issue · 1 comments

Hello,

I am having difficulties saving the figure generated by Dictys.

For exemple, for Heatmap of regulation strengths between select TFs and their top targets in select cell types.

I tried to save using:
fig,fig_colorbar,net=fig_heatmap_top(d0,tf,ntop=ntop,direction=direction,aspect=1,gann='all')
plt.savefig("figname.png") but this is only saving the legend.

Could you please help me to find the way to save the figure ?

For :

TF discovery based on 4 patterns of highly variable regulatory activity over developmental trajectory (discovery.ipynb)

I used:
#Value range for coloring
vrange={
'Terminal logFC':[-4.5,4.5],
'Transient logFC':[-1.5,1.5],
'Switching time':[0.2,0.8],
}

for branchname in branches:
print(branchname)
figs=d0.draw_discover(*branches[branchname],ntops=(12,12,2,2),vrange=vrange)
plt.show()
for i,fig in enumerate(figs):
fig[0].savefig('TF_Discovery--branch{}-fig{}.png'.format(branchname,i), bbox_inches='tight', dpi = 300)

But I am not sure I can use this here.

Maybe it could be useful to add exemples for saving this figure in the notebooks ?

Thanks a lot !

Hi JasonOSS,

Thank you for the suggestion. Yes, you should do fig.savefig('fig.png') and fig_colorbar.savefig('colorbar.png') instead. See https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure.savefig.

I will add some note on saving figures in the next version. You are welcome to let us know if you have any additional suggestions or questions.

Lingfei