silx icon indicating copy to clipboard operation
silx copied to clipboard

How about a posibility to save the aspect ration option in SILX_style?

Open linupi opened this issue 2 years ago • 6 comments

Working with 2d datasets in NeXus hdf5 with different units on the x- and y-axis I was wondering if there is a way to tell silx view to open a NXdata image view with the option "Do not keep data aspect ration" activated? By default it seems to keep the aspect ratio.

Would the the SILX_style be an appropriate place?

https://github.com/silx-kit/silx/blob/360f890a617676a92f0bed6a28b718d09e70ec03/src/silx/io/nxdata/parse.py#L64

linupi avatar Jun 29 '22 09:06 linupi

HI Linus,

Have you checked in the menu? I think there is a default aspect ration option. But i dont remember if it is applied for the NXdata.

vallsv avatar Jun 29 '22 09:06 vallsv

Also, i think it was already discussed, but if the units dosen't match i think there is no need to apply by default the constraint on the aspect ratio.

This have to be checked with @t20100, but in this case, this could be set as the default behaviour in silx?

vallsv avatar Jun 29 '22 09:06 vallsv

Yes that would make sense to enable "keep aspect ratio" only when the units of both axes are the same. If that's not enough, we can also consider extending SILX_style to include a toggle about the aspect ratio

t20100 avatar Jul 20 '22 12:07 t20100

Basic solution would be to add a keep_aspect_ratio boolean.

But, I propose to add an aspect (or aspect_ratio) field which can be either equal or auto. It leaves more room for extensions than a boolean. This is inspired from: https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_aspect.html#matplotlib.axes.Axes.set_aspect

attn @loichuder @axelboc : What do you think? This needs to be sync between silx and h5web.

t20100 avatar Aug 26 '22 14:08 t20100

In h5web, the aspect ratio setting is saved when the user changes it which seem to alleviate the issue at hand.

Is it reset each time you load a dataset in silx ?

If we decide to extend SILX_style, I would be more inclined towards having a aspect_ratio field with set values rather than a boolean.

loichuder avatar Aug 26 '22 14:08 loichuder

In h5web, the aspect ratio setting is saved when the user changes it which seem to alleviate the issue at hand.

Not completely since you can have multiple nxdata in the same file. But yeah, it makes it complicated to mix both.

Is it reset each time you load a dataset in silx ?

It is not saved as a preference when you restart the app. It is however kept when you change from one dataset to another and keep the same vis...

t20100 avatar Aug 26 '22 15:08 t20100

Seems to me like checking the units is enough, at least for now. If we implement this in H5Web, we'll have to review how the layout option is persisted. I'll open an issue in the repo.

axelboc avatar Sep 05 '22 11:09 axelboc

Proposition: Keep aspect ratio by default and disable it when axes have different @units (i.e., keep aspect ratio for axes with the same @units or without @units - if an axis as @units and the other not, it's different @units) and see if that is enough before extending SILX_style.

Would that be OK?

t20100 avatar Sep 05 '22 12:09 t20100