Open LucaMarconato opened 1 year ago
Hello devs,
I have a really cool function on my hands, and I saving a summary plot is proving to be quite difficult. So I am kinda restarting this issue.
My function would take an image as an input, perform segmentation of the image using Cellpose via SOPA, and produce a PNG file with a hyperparameter search, to decide what is the best segmentation.
Currently I am running this code for plotting each ax object, in a fig that has many axes.
sdata.pl.render_images(
element=args.image_key, alpha=0.85, channel=config['channels'], palette=['green']
).pl.render_shapes(
element=title, fill_alpha=0.0, outline=True, outline_width=1.1, outline_color="yellow", outline_alpha=0.32
).pl.show(ax=ax, title=title, save=os.path.join(args.output, "pngs", "segment_search.png"))
When this line is reached in the CLI a matplotlib popup comes up with the entire figure, but a single filled ax object. I have to manually close this first figure, and then the other axes are plotted, and then the entire figure saved (I think overwriting itself).
I have looked into matplotlib docs but I found no clear answer.
Any tips, ideas, or comments, very welcome. For the plotting or the function in general.
Best, Jose
I refer to the code mentioned in this other issue: https://github.com/scverse/spatialdata-plot/issues/68
This code here:
doesn't work if I run the code as a script, but it works in interactive mode (where because of a bug the plots are not shown until I call
plt.show()
). I suggest to do like scanpy and having a parametershow: bool
. I suggest also that if the parameterax
is notNone
, thenshow
is set toFalse
. I don't remember if this one is also a behavior of scanpy, but I think it's reasonable.