adding slice functionality to matlab_plotly and fix issue #312 #431
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In favor of fixing all pending issues, this time I was working with issue #312. This issue is related to the MATLAB
slice
functionality. When trying to replicate the charts of theslice
functionality, the previousmatlab_plotly
code resulted in bad plotly charts. This is basically because theslice
functionality was not implemented inmatlab_plotly
. With this PR I have added this functionality by coding all the related code from scratch.Specifically, I have fully coded the
updateSlice.m
file with which the charts of the slice functionality are now properly created with plotly.It is important to note that to use the
slice
functionality, it is necessary to set the optional parameter'TreatAs'
to'slice'
.Below I share examples of use taken from the MATLAB page
Volume Data Along Slices
Show volumetric data along slice planes that are orthogonal to each axis.
Create slice planes through the volume defined by v=xe−x2−y2−z2, where x, y, and z range from [-2,2]. Create slice planes orthogonal to the x-axis at the values -1.2, 0.8, and 2 and orthogonal to the z-axis at the value 0. Do not create any slice planes that are orthogonal to the y-axis by specifying an empty array.
Volume Data Along Surface
Show volumetric data along a nonplanar slice. Define the surface where you want to show the volumetric data.
Create volume array V as the volume defined by v=xe−x2−y2−z2, where x, y, and z range from [-5,5]. Then, show a slice of the volume data along the surface defined by z=x2−y2.
Specify Interpolation Method
Create a slice plane through volumetric data. Specify the interpolation method for the data values.
Create a slice plane orthogonal to the x-axis at the value 0.8. Since the volume data is not defined for x values of 0.8, the slice function interpolates the nearby values. To use the nearest data point value, specify the interpolation method as 'nearest'.
EXTRA:
Previous example use FaceColor = 'flat' to coloring the slice surface chart. But the updated code works for FaceColor = 'interp' as well.
Bellow the result. Please note how the face color is now corresponding to interp