TransWikia.com

How do I get `ArrayMesh` to reverse the order of data in a 3D array?

Mathematica Asked on January 11, 2021

The following array has non-zero entries in the cells where all three indices are equal:

foo = SparseArray[{i_, i_, i_} -> 1, {4, 4, 4}]

When I try to render this in ArrayMesh, though, the resulting graphic has the third axis reversed:

ArrayMesh[foo, PlotTheme -> "Scientific", AxesLabel -> {i, j, k}]

enter image description here

The filled cells should be on the diagonal going from the lower left to the upper right.

Using the DataReversed -> True option appears to reverse the first axis only (or equivalently, the second and third axes while leaving the first axis the same):

ArrayMesh[foo, PlotTheme -> "Scientific", DataReversed -> True, AxesLabel -> {i, j, k}]

enter image description here

Trying to set an option such as DataReversed -> {True, False} or DataReversed -> {True, False, True} results in a graph identical to the first graph.

Is there a way to get Mathematica to render all three axes in the correct order? I am using MM 12.0.0 on a Mac, in case this is version-dependent.

One Answer

Indeed an annoyance. Apparently, vector-valued settings for DataReversed are just ignored. Something for support, I guess.

Does

ArrayMesh[Map[Reverse, foo, 1], PlotTheme -> "Scientific", AxesLabel -> {i, j, k}]

do what you want?

Answered by Henrik Schumacher on January 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP