help-octave
[Top][All Lists]
Advanced

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

Re: Octave plot on time/date x-axis


From: Ivan Sutoris
Subject: Re: Octave plot on time/date x-axis
Date: Mon, 15 Sep 2008 20:49:07 +0200

> I would like to plot a data set that has dates and time in the x-axis. I
> have found the following code, but when I enter it i get a parse error:
> syntax error.
>
>  __gnuplot_set xdata time
>  __gnuplot_set timefmt "%d/%m"
>  __gnuplot_set format x "%b %d"

I think Octave no longer allows to directly access gnuplot, so these
commands won't work. I don't know if there is some simple way to have
dates as tick labels, but you can always set tick labels manually,
like this:

data = [2 3 5 3.5 6];
datalabels = {'10/3/2008','10/4/2008','10/5/2008','10/6/2008','10/7/2008'};
% cell array
plot(data)
set(gca(),'xticklabels',datalabels)

Depending on your data, you could probably use something like
datestr() to fill cell array with respective dates as strings. Setting
graphic properties with get() and set() functions is documented in
Octave manual (section about advanced plotting), and since Octave
developers try to keep things compatible with MATLAB, I've found
reference on Mathworks site also useful.

Hope this helped
Ivan Sutoris


reply via email to

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