Location of plot for subplot(2,2,3)

2 views (last 30 days)
Jeong-Phill Kim
Jeong-Phill Kim on 12 Jan 2021
Answered: dpb on 12 Jan 2021
For a subplot(2,2,3), the plot is located in 3-rd position in 2x2 matrix form.
Up to now the plot is placed in the lower left corner.
However, this seems to violate the consistency in treating a matrix element to a 1D vectors,
In Matlab, 2D matrix elements are interpredted as
A(1,1) --> B(1)
A(2,1) --> B(2)
A(1,2) --> B(3)
A(2,2) --< B(4)
This is general rule for matrix operation in Matla, that is, column first.
Therefore, the index of plot location shoul be matched to the general rule in matrix operation.
Concludingly, I think that it is reasonable for subplot(2,2,3) to place a plot in upper right corner, not lower left corner.
How about your idea.
I want to ask a guy who is in charge of this work to consider this issue in deep.

Answers (2)

Steven Lord
Steven Lord on 12 Jan 2021
For a subplot(2,2,3), the plot is located in 3-rd position in 2x2 matrix form.
Up to now the plot is placed in the lower left corner.
However, this seems to violate the consistency in treating a matrix element to a 1D vectors,
Yes, and I believe that has been the way subplot has behaved since it was introduced several decades ago. No, I don't know why that choice was made. It predates the start of my tenure at MathWorks.
Were we to redesign subplot today, I suspect we would consider making it number its subplots in column-major order (or at least giving that as an option.) But changing the default behavior of the function now would be a major backwards incompatibility (see: several decades) that could break a lot of users' programs.

dpb
dpb on 12 Jan 2021
The logic is sound but as Steven L points out, it would break existing code going back to the beginning of time so TMW will never make the change to switch orders.
If you're writing code for yourself and would find it convenient to have that ordering consistent with other functions, you can create an interface routine that does the transposition for you and then calls the TMW function; however, you would not want to change the builtin behavior of subplot or alias it if others need to use your code.

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!