[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 'XTickLabel' - different type from Matlab's
From: |
Ben Abbott |
Subject: |
Re: 'XTickLabel' - different type from Matlab's |
Date: |
Sat, 26 Nov 2011 12:49:41 -0500 |
On Nov 26, 2011, at 11:24 AM, J. Luis wrote:
> Hi,
>
> I noticed another difference in behavior towards Matlab regarding the
> 'XTickLabel' axes property.
>
> octave.exe:3> h=plot(rand(1,2))
> h = -1.5394
> octave.exe:4> get(get(h,'Parent'),'XTickLabel')
> ans =
> {
> [1,1] = 1
> [1,2] = 1.2
> [1,3] = 1.4
> [1,4] = 1.6
> [1,5] = 1.8
> [1,6] = 2
> }
> octave.exe:5> whos
> Variables in the current scope:
>
> Attr Name Size Bytes Class
> ==== ==== ==== ===== =====
> ans 1x6 14 cell
> h 1x1 8 double
>
> When I do the same in ML I see that 'ans' is a char matrix
>
> ans 11x3 66 char
>
> Joaquim
This looks like a subtle incompatibility to me. In both ML and Octave the
following render identical results ...
set (gca, 'xticklabel', [0, 0.2, 0.4, 0.6, 0.8, 1]
xticklabel1 = get (gca, 'xticklabel');
set (gca, 'xticklabel', '0|0.2|0.4|0.6|0.8|1')
xticklabel2 = get (gca, 'xticklabel');
set (gca, 'xticklabel', ['0 '; '0.2'; '0.4'; '0.6'; '0.8'; '1 '])
xticklabel3 = get (gca, 'xticklabel');
set (gca, 'xticklabel', {'0', '0.2', '0.4', '0.6', '0.8', '1'})
xticklabel4 = get (gca, 'xticklabel');
whos xticklabel1 xticklabel2 xticklabel3 xticklabel4
ML uses the 3rd variant for the default xticklabel values., and Octave uses the
4th (1x6 cellstr)
Each set() statement works in both Octave and ML. However, the resulting values
returned by the get() are different.
Octave returns ...
Variables in the current scope:
Attr Name Size Bytes Class
==== ==== ==== ===== =====
xticklabel1 1x6 48 double
xticklabel2 1x19 19 char
xticklabel3 6x3 18 char
xticklabel4 1x6 14 cell
And ML ...
Name Size Bytes Class Attributes
xticklabel1 6x3 36 char
xticklabel2 6x3 36 char
xticklabel3 6x3 36 char
xticklabel4 6x1 700 cell
I see three differences.
(1) The default xticklabel values for ML are char, and are cell (cellstr) for
Octave.
(2) ML converts the xticklabel with class double or char with "|" used as a
delimiter to a char array. Octave returns the same class and format as was
passed to set().
(3) ML converts a cellstr column vector to a row vector.
I've filed a bug report.
https://savannah.gnu.org/bugs/index.php?34906
Ben