[Scilab-users] Plotting time (hours) in scilab

Stefan Du Rietz sdr at durietz.se
Thu Jun 5 14:04:56 CEST 2014


On 2014-06-05 13:00, Stefan Du Rietz wrote:
> On 2014-06-05 12:41, Stefan Du Rietz wrote:
> --------------------
>> On 2014-06-05 11:29, Edmund Okoroigwe wrote:
>> --------------------
>>> I want to plot time  (8:00,9:00,10:00,11:00, 12:00, 13:00,14:00) as
>>> x-axis. How can I achieve this. The data is saved in excel file.
>>> Thanks
>>>
>>> Edmund
>>>
>> Maybe like this:
>>
>> t = 8:14;
>> a = gca();
>> // Set the x-axis limits to the first and last element of t
>> a.tight_limits = "on";
>> a.data_bounds(:, 1) = t([1 $])';
>> // Set the ticks and format the labels
>> a.x_ticks = tlist(["ticks","locations","labels"], ...
>>    t, msprintf("%02i:00\n", t'));
>>
>> Here the x-axis is scaled in hours. If you have each time (date and
>> time) as a vector [year month day hour minute second] you can convert
>> them with datenum() to get numbers with one day = 1.0 (and one hour =
>> 1/24).  See the help on datenum() and msprintf().
>
> Sorry, I mishandled the transpose operators!
>
> t = (8:14)';
> a = gca();
> // Set the x-axis limits to the first and last element of t
> a.tight_limits = "on";
> a.data_bounds(:, 1) = t([1 $])';
> // Set the ticks and format the labels
> a.x_ticks = tlist(["ticks","locations","labels"], ...
>    t, msprintf("%02i:00\n", t));
>
Once again ...
After fixing t, I forgot to change to this:

a.data_bounds(:, 1) = t([1 $]);

>> Regards
>> Stefan




More information about the users mailing list