fixing issues #387, #389 and other ones #406
Merged
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.
This PR fix several issues. In particular:
issue #389
The most complicated was the issue Create Subplots with Polar Axes. This is because the axes used are polar and the previous
matlab_plotly
code was not robust enough with polar axes. This worked when using only one axes, but not with multiple axes (subplots). To solve this I had to recode severalmatlab_plotly
functions. Specifically, to handle MATLAB polar plots, Plotlyscatterpolar
is used. The initial philosophy ofmatlab_plotly
sets/creates Cartesian axes, therefore each function in the original code ofmatlab_plotly
linked the traces used to Cartesian axes. The challenge lies, in this case, in linkingscatterpolar
with polar axes. To do this, the polar axes must be created using layout.polar and then linked to Plotly'sscatterpolar
using itssubplot
method.Another challenge is handling empty axes. For this create a logic, which identifies the empty axes and labels them as
'nothing'
. So whenupdateData.m
receives a'nothing'
class it executes a special function that I coded (calledupdateOnlyAxes.m
). This function only uses a trace with empty data so thatmatlab_plotly
can display the respective empty axes.I share below screenshots of results for all the examples in the code flow of the previous link.
Upper and Lower Subplots
Create a figure with two stacked subplots. Plot a sine wave in each one.
Quadrant of Subplots
Create a figure divided into four subplots. Plot a sine wave in each one and title each subplot.
Subplots with Different Sizes
Create a figure containing with three subplots. Create two subplots across the upper half of the figure and a third subplot that spans the lower half of the figure. Add titles to each subplot.
Replace Subplot with Empty Axes
Create a figure with four stem plots of random data. Then replace the second subplot with empty axes.
Subplots at Custom Positions
Create a figure with two subplots that are not aligned with grid positions. Specify a custom position for each subplot.
Create Subplots with Polar Axes
Create a figure with two polar axes. Create a polar line chart in the upper subplot and a polar scatter chart in the lower subplot.
Modify Axes Properties After Creation
Create a figure with two subplots. Assign the Axes objects to the variables ax1 and ax2. Specify the Axes objects as inputs to the plotting functions to ensure that the functions plot into a specific subplot.
Make Subplot the Current Axes
Create a figure with multiple subplots. Store the Axes objects in vector ax. Then make the second subplot the current axes. Create a line chart and change the axis limits for the second subplot. By default, graphics functions target the current axes.
Convert Existing Axes to Subplot
Create a line chart. Then convert the axes so that it is the lower subplot of the figure. The subplot function uses the figure in which the original axes existed.
Convert Axes in Separate Figures to Subplots
Combine axes that exist in separate figures in a single figure with subplots.
Create two plots in two different figures. Assign the Axes objects to the variables ax1 and ax2. Assign the Legend object to the variable lgd.
ax2 = gca;
Create copies of the two Axes objects using copyobj. Specify the parents of the copied axes as a new figure. Since legends and colorbars do not get copied with the associated axes, copy the legend with the axes.
Issue #387
I share below screenshots of results for all the examples in the code flow of the previous link.
Position Multiple Axes in Figure
Position two Axes objects in a figure and add a plot to each one.
Specify the position of the first Axes object so that it has a lower left corner at the point (0.1 0.1) with a width and height of 0.7. Specify the position of the second Axes object so that it has a lower left corner at the point (0.65 0.65) with a width and height of 0.28. By default, the values are normalized to the figure. Return the Axes objects as ax1 and ax2.
Add a plot to each Axes object.
Specify the axes by passing it as the first input argument to the graphics function. Most graphics functions reset some axes properties, such as the tick values and labels. However, they do not reset the axes position.
Make Axes the Current Axes
Create two overlayed Axes objects. Then, specify the current axes and add a plot.
First create two Axes objects and specify the positions. Display the box outline around each axes. Return the Axes objects as ax1 and ax2.
Make ax1 the current axes. This action brings the axes to the front of the display and makes it the target for subsequent graphics functions. Add a line plot to the axes.