help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Specifying RGB triples


From: Sergei Steshenko
Subject: Re: Specifying RGB triples
Date: Thu, 21 Apr 2011 08:24:37 -0700 (PDT)


--- On Thu, 4/21/11, Andy Buckle <address@hidden> wrote:

> From: Andy Buckle <address@hidden>
> Subject: Re: Specifying RGB triples
> To: "Sergei Steshenko" <address@hidden>
> Cc: "Søren Hauberg" <address@hidden>, address@hidden
> Date: Thursday, April 21, 2011, 4:29 AM
> On Thu, Apr 21, 2011 at 10:40 AM,
> Sergei Steshenko <address@hidden>
> wrote:
> >
> >
> > --- On Thu, 4/21/11, Søren Hauberg <address@hidden>
> wrote:
> >
> >> From: Søren Hauberg <address@hidden>
> >> Subject: Re: Specifying RGB triples
> >> To: "Sergei Steshenko" <address@hidden>
> >> Cc: address@hidden
> >> Date: Thursday, April 21, 2011, 1:58 AM
> >> tor, 21 04 2011 kl. 01:14 -0700,
> >> skrev Sergei Steshenko:
> >> >
> >> > --- On Thu, 4/21/11, Søren Hauberg <address@hidden>
> >> wrote:
> >> >
> >> > > From: Søren Hauberg <address@hidden>
> >> > > Subject: Re: Specifying RGB triples
> >> > > To: "pathematica" <address@hidden>
> >> > > Cc: address@hidden
> >> > > Date: Thursday, April 21, 2011, 12:06
> AM
> >> > > ons, 20 04 2011 kl. 23:56 -0700,
> >> > > skrev pathematica:
> >> > [snip]
> >> > >   plot (sin (1:100), 'color',
> >> [0.9, 0.2, 0.2])
> >> > [snip]
> >> > >
> >> > > Søren
> >> > >
> >> > >
> >> >
> >> > Is this described anywhere in Octave
> documentation ?
> >>
> >> I don't know.
> >>
> >> > And how this can be understood from
> "get(gcf())"
> >> output ?
> >>
> >> "get(gcf())" just gives you a list of figure
> properties,
> >> such as the
> >> size of the figure, etc. The above colour-stuff is
> the
> >> property of a
> >> specific plot element. You should be able to get
> related
> >> information by
> >> doing something like
> >>
> >>   handle = plot (sin (1:100));
> >>   get (handle)
> >>
> >> Søren
> >>
> >>
> >
> > You example among other things produces:
> >
> > "
> >  color =
> >
> >     0   0   1
> > ".
> >
> > How am I supposed from the above output to know that
> 'color' should be
> > specified as vector and not as, say, string or cell
> array ?
> >
> > Thanks,
> >  Sergei.
> 
> The "above output" alone won't tell you. But the following
> does not
> seem too stressful.
> 
> >c=get (gca(),'color')
> c =
> 
>    1   1   1
> 
> >whos c
> Variables in the current scope:
> 
>   Attr Name        Size 
>                
>    Bytes  Class
>   ==== ====        ==== 
>                
>    =====  =====
>        c     
>      1x3       
>              
>    24  double
> 
> Total is 3 elements using 24 bytes
> 
> -- 
> /* andy buckle */
> 

The above output shows defective design. Which causes confusion and need
to write documentation.

Here is a counter-example from Perl:

address@hidden:~/junk> cat -n data_dumper_demo.pl
     1  #!/usr/bin/perl
     2
     3  use strict;
     4  use warnings;
     5
     6  use Data::Dumper;
     7
     8  $Data::Dumper::Deepcopy = $Data::Dumper::Deepcopy = 1;
     9  $Data::Dumper::Indent = $Data::Dumper::Indent = 1;
    10  $Data::Dumper::Terse = $Data::Dumper::Terse = 1;
    11  $Data::Dumper::Sortkeys = $Data::Dumper::Sortkeys = 1;
    12
    13
    14  my $foo =
    15    {
    16    colors => [0.1, 0.2, 0.3],
    17    another_level =>
    18      [
    19        {
    20        one => 1,
    21        two => 2
    22        },
    23
    24      3
    25      ]
    26    };
    27
    28
    29  my $foo_as_string = Dumper($foo);
    30
    31  warn "\$foo_as_string=$foo_as_string";
    32
    33  my $reconstituted_foo = eval $foo_as_string;
    34
    35  my $reconstituted_foo_as_string = Dumper($reconstituted_foo);
    36
    37  warn "\$reconstituted_foo_as_string=$reconstituted_foo_as_string";
address@hidden:~/junk> ./data_dumper_demo.pl
$foo_as_string={
  'another_level' => [
    {
      'one' => 1,
      'two' => 2
    },
    3
  ],
  'colors' => [
    '0.1',
    '0.2',
    '0.3'
  ]
}
$reconstituted_foo_as_string={
  'another_level' => [
    {
      'one' => 1,
      'two' => 2
    },
    3
  ],
  'colors' => [
    '0.1',
    '0.2',
    '0.3'
  ]
}
address@hidden:~/junk>

- _no_ questions need to be asked about types of entities - because
Data::Dumper prints in _Perl_ format.

GNU Octave prints/dumps internal data in all kinds of formats which
are neither descriptive enough nor compatible with Octave itself.

In the above example [...] denote anonymous array reference, so it's
obviously clear how 'color' is to be specified.

Regards,
  Sergei.









reply via email to

[Prev in Thread] Current Thread [Next in Thread]