help-octave
[Top][All Lists]
Advanced

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

Re: Setting grid with personalized scale


From: Ben Abbott
Subject: Re: Setting grid with personalized scale
Date: Thu, 26 Nov 2009 14:40:43 -0500

On Nov 26, 2009, at 12:55 PM, Renato S. Yamane wrote:

> Ben Abbott wrote:
>> Renato S. Yamane wrote:
>>> On 25-11-2009 10:07, Ben Abbott wrote:
>>>> clf
>>>> x = 1:1000;
>>>> semilogx (x, sqrt(x))
>>>> a = [1, 2, 3, 5];
>>>> xtick = [a, 10*a, 100*a, 1000];
>>> 
>>> So, xtick is:
>>> 1, 2, 3, 5, 10, 20, 30, 50, 100, 200, 300, 500, 1000
>>> 
>>>> set (gca, 'xtick', xtick)
>>> 
>>> What it does?
>>> 
>>>> set (gca, 'xticklabel', 
>>>> {'1','2','3','5','10','20','30','50','100','200','300','500','10k'})
>>> 
>>> So sorry for this questions, I did it because I try change somethings in
>>> your suggestion but it don't work...
>>> 
>>> Like this:
>>> - X-axis:
>>> 20, 30, 50, 100, 200, 300, 500, 1k, 2k, 3k, 5k, 10k, 20k
>> 
>> 
>> The "xtick" axis property defines where the tick marks are to be placed for 
>> the x-axis.
>> 
>> The "xticklabel" property defines the text lables for each x-axis tick mark.
>> 
>> For your example, try
>> 
>> set (gca, "xtick", [20, 30, 50, 100, 200, 300, 500, 1000, 2000, 3000, 5000, 
>> 10000, 20000]);
>> set (gca, "xticklabel", {"20", "30", "50", "100", "200", "300", "500", "1k", 
>> "2k", "3k", "5k", "10k", "20k"]);
>> 
>> If that doesn't work, tell us what version of octave you are running. You'll 
>> need to be running 3.2.x for this to work.
> 
> Hi Ben, I'm using Octave 3.2.3 on Debian Squeeze.
> See the graphs attached.
> 
> - standard_output.jpg = Standard output using semilogx;
> - with_xtick.jpg = After use "set (gca, "xtick", [20, 30...]"
> - with_xtick_label.jpg = After use "set (gca, "xticklabel", ["20", "30"...]
> 
> How you can see, the labels is not ok.
> 
> Regards,
> Renato
> <standard_output.jpg><with_xtick.jpg><with_xtick_label.jpg>

The "xticklabels" need to be bracketed by {}, not [].

Here's an example.

x = 20:20000;
semilogx (x, sqrt(x))
set (gca, "xtick", [20, 30, 50, 100, 200, 300, 500, 1000, 2000, 3000, 5000, 
10000, 20000]);
set (gca, "xticklabel", {"20", "30", "50", "100", "200", "300", "500", "1k", 
"2k", "3k", "5k", "10k", "20k"});
xlim ([20, 20e3])
print -dpng test.png

You can see the result at the link below.

http://picturehosting.com/gallery.php?g=semilogx-with-xticklabels&u=bpabbott&i=test.png

Ben




reply via email to

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