Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Problem
Currently, the antialiasing filter used by imshow() is applied both in the x and the y direction. There are cases where "image-like" data is highly sampled in one direction (requiring antialiasing) but not in the other, and also has some nans; an example is a kymograph like subfigure 1c athttps://www.nature.com/articles/s41467-017-01462-y/figures/1
For such data, the current default interpolation settings (antialiased + rgba (becauseone of the directions is oversampled) can yield not nice artefacts, in particular at the boundary between "data" and "nan":
frompylabimport*vals=np.full((50,500),np.nan)fori,rowinenumerate(vals):n=200+np.random.randint(300)row[:n]=np.sin(np.arange(n)/10+i/5)# make some fake dataaxs=figure(layout="constrained",figsize=(10,10)).subplots(3,3,subplot_kw={"xticks": [],"yticks": []})fori,interpolationinenumerate([None,"none","antialiased"]):forj,stageinenumerate([None,"data","rgba"]):axs[i,j].text(0,0,f"{interpolation=},{stage=}",bbox={"fc":"w"})axs[i,j].imshow(vals.T,aspect="auto",origin="lower",interpolation=interpolation,interpolation_stage=stage)show()
For this specific dataset, the best settings currently available is probably to go back to interpolation="data". But ideally, it would be nice if it was possible to have a separable antialiasing filter (I don't actually know if the current one is separable), so that one can apply it (here) only in the vertical direction (ideally in rgba space).
Proposed solution
No response