help-octave
[Top][All Lists]
Advanced

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

RE: Loading tick labels from a file


From: Byron Hawkins
Subject: RE: Loading tick labels from a file
Date: Tue, 25 Feb 2014 12:05:33 -0800

On Feb 24, 2014, at 1:12 PM, Byron Hawkins <address@hidden>
wrote:

> 
> On Feb 24, 2014, at 5:16 AM, Byron Hawkins <address@hidden>
> wrote:
> 
>> I'm trying to make a generic octave script for generating some basic
> plots, and I need to load the tick labels from a file. This works for 
> numeric labels:
>> 
>> tick_labels = dlmread(args{4})
>> 
>> But when I have a text label like "1K", it shows up on the axis as 
>> "0". I
> tried a variety of other loading functions, but the result was the 
> same. Is there a way to specify that the contents are text and should 
> be treated as if quoted? Thanks for your help.
>> 
>> Byron
> 
> Can you give us an example of the file you are reading?  Does it 
> contain all labels with double quotes on one line? Or one label on 
> each line without any quotes, or something else?
> 
> Ben
> 
> I've tried a few ways. When I put them on separate lines, the labels 
> show up on the wrong tick marks, so I mostly experimented with them all on
one line.
> For example:
> 
> 1,10,100,1K
> 
> And:
> 
> 1,10,100,"1K"
> 
> And:
> 
> 1,10,100,'1K'
> 
> What's the normal way to do this?

Assuming the labels are in "foo.txt" and that the contents of foo.txt is ...

1,10,100,1K

Try ...

        labels = strsplit (fileread ('foo.txt'), ',')

Ben

-------

Thanks, it works, only now I get an error while generating the plot:

    multiplot> set ytics in scale  1.4 border mirror ( "0" 0.05,  "1" 1,
"10" 10,  "100" 100,  "1K"
    line 0: constant expression required

    multiplot> " 1000) textcolor rgb "
    line 0: invalid command

Here is the snippet of script that loads the tick marks:

    if strcmp(args{input}, "-t"),
      input++;

      printf("Loading tickmark positions from %s\n", args{input});
      tick_positions = dlmread(args{input++});

      printf("Loading tickmark labels from %s\n", args{input});
      tick_labels = strsplit(fileread(args{input++}), ',');

      set(gca, 'ytick', tick_positions);
      set(gca, 'yticklabel', tick_labels);
    end;

Strangely, it works for small plots where values are all less than 100. I
tried changing the labels "1K" to plain numbers, but that didn't make a
difference. The maximum value in the plot data is still less than 1000. Can
you tell me where I can get more information about what the error means?




reply via email to

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