DimensionalData.jl icon indicating copy to clipboard operation
DimensionalData.jl copied to clipboard

Different plots when using `Observable`

Open DylanMMarques opened this issue 10 months ago • 9 comments

Hello,

The axes are not permuted and reordered when plotting Observable{DimArray} creating different plots when using Observable. Also, the axes label are not displayed.

using DimensionalData, CairoMakie
dimarray = rand(Y(3), X(7))
fig, ax, plt = series(dimarray)
series(fig[1,2], Observable(dimarray))

Image

Probably related with #724

DylanMMarques avatar Jan 19 '25 15:01 DylanMMarques

I didn't know that dispatch was even a thing in Makie, doesn't it need to be series! ? We are modifying an existing object...

rafaqz avatar Jan 19 '25 16:01 rafaqz

This might be a dispatch that I did not catch in #743. Does this with a normal array?

felixcremer avatar Jan 19 '25 16:01 felixcremer

Can you try an Axis as first argument?

felixcremer avatar Jan 19 '25 16:01 felixcremer

series! would require a axis. series creates an axis in fig[1,2]

As far as I am aware, the code I posted above is equivalent to:

using DimensionalData, CairoMakie
dimarray = rand(Y(3), X(7))
fig, ax, plt = series(dimarray)
ax2 = Axis(fig[1,2])
series!(ax2, Observable(dimarray))
fig 

Image

Yes, it does work with a normal array both using series and series! (not sure if this is what you were asking):

array = rand(3, 7)
fig, ax, plt = series(array)
ax2 = Axis(fig[1,2])
series!(ax2, Observable(array))
fig 

Image

DylanMMarques avatar Jan 19 '25 17:01 DylanMMarques

I'm saying series without ! may work, but it shouldn't ;)

Also wondering if this is a Makie bug.

@asinghvi17 should Makie conversions always happen to the contents of an observable too?

rafaqz avatar Jan 19 '25 17:01 rafaqz

Yes always, if they don't it's because we override the plot functions...

asinghvi17 avatar Jan 19 '25 18:01 asinghvi17

Yes always, if they don't it's because we override the plot functions...

asinghvi17 avatar Jan 19 '25 18:01 asinghvi17

The problem seems to be specific to series because with plot I get the same plot from an Observable and from a plain DimArray. The only thing is, that the plot! function does not add the labels, because they are set on the Axis I think. But the dimension lookup is used.

With the Observable it is using a fallback method in MakieCore and takes the dimarray as a normal array.

felixcremer avatar Jan 19 '25 22:01 felixcremer

With the Observable it is using a fallback method in MakieCore and takes the dimarray as a normal array.

This should never be the case. I wonder if we're missing a convert for series...

asinghvi17 avatar Jan 20 '25 00:01 asinghvi17