|
From: theozh <th...@gm...> - 2018-10-12 19:00:20
|
Hello,
is there a way to plot as function of the weekday or as function of weekday+daytime?
I can plot as function of day and as function of daytime, but haven't yet found a way for weekday or weekday+daytime.
Probably, I have to define a function to convert weekday into a number from 0 to 6 (or 1 to 7) and add the daytime as a fraction? Or maybe I overlooked a simple, obvious way?
In the below example I get "warning: Bad time format in string". Could this be a conflict with locale/language settings?
Thank you for hints.
Theo.
The following code should illustrate for testing purpose.
### plot as a function of weekday
# generate some random test data
set print $BirthData
do for [i=1:100] {
RandomDate = rand(0)*1.5e9
RandomNumber = rand(0)*100
print(strftime("%a %d.%m.%Y %H:%M:%S", RandomDate)." ".sprintf("%g",RandomNumber))
}
set print
print $BirthData
set multiplot layout 3,1
set xdata time
set format x "%Y"
plot $BirthData u (timecolumn(2,"%d.%m.%Y")):4
set format x "%H:%M"
plot $BirthData u (timecolumn(3,"%H:%M")):4
set format x "%a"
plot $BirthData u (timecolumn(1,"%a")):4 # does not work! "warning: Bad time format in string"
unset multiplot
### end of code
|
|
From: Alan C. <ala...@gm...> - 2018-10-12 19:36:59
|
I don't begin to understand all that but see %u and %w in the strftime
man page. You can get an integer 1-7 or 0-6.
On 10/12/18, theozh <th...@gm...> wrote:
> Hello,
> is there a way to plot as function of the weekday or as function of
> weekday+daytime?
>
> I can plot as function of day and as function of daytime, but haven't yet
> found a way for weekday or weekday+daytime.
> Probably, I have to define a function to convert weekday into a number from
> 0 to 6 (or 1 to 7) and add the daytime as a fraction? Or maybe I overlooked
> a simple, obvious way?
> In the below example I get "warning: Bad time format in string". Could this
> be a conflict with locale/language settings?
>
> Thank you for hints.
> Theo.
>
> The following code should illustrate for testing purpose.
>
> ### plot as a function of weekday
> # generate some random test data
> set print $BirthData
> do for [i=1:100] {
> RandomDate = rand(0)*1.5e9
> RandomNumber = rand(0)*100
> print(strftime("%a %d.%m.%Y %H:%M:%S", RandomDate)."
> ".sprintf("%g",RandomNumber))
> }
> set print
> print $BirthData
>
> set multiplot layout 3,1
>
> set xdata time
> set format x "%Y"
> plot $BirthData u (timecolumn(2,"%d.%m.%Y")):4
>
> set format x "%H:%M"
> plot $BirthData u (timecolumn(3,"%H:%M")):4
>
> set format x "%a"
> plot $BirthData u (timecolumn(1,"%a")):4 # does not work! "warning: Bad
> time format in string"
>
> unset multiplot
> ### end of code
>
>
>
>
>
>
> _______________________________________________
> gnuplot-info mailing list
> gnu...@li...
> Membership management via:
> https://lists.sourceforge.net/lists/listinfo/gnuplot-info
>
--
-------------
No, I won't call it "climate change", do you have a "reality problem"? - AB1JX
Cities are cages built to contain excess people and keep them from
cluttering up nature.
Impeach Impeach Impeach Impeach Impeach Impeach Impeach Impeach
|
|
From: BBands <bb...@gm...> - 2018-10-12 21:30:59
|
Does this help? https://stackoverflow.com/questions/17791828/gnuplot-date-time-in-x-axis John On Fri, Oct 12, 2018 at 12:00 PM theozh <th...@gm...> wrote: > > Hello, > is there a way to plot as function of the weekday or as function of weekday+daytime? > > I can plot as function of day and as function of daytime, but haven't yet found a way for weekday or weekday+daytime. > Probably, I have to define a function to convert weekday into a number from 0 to 6 (or 1 to 7) and add the daytime as a fraction? Or maybe I overlooked a simple, obvious way? > In the below example I get "warning: Bad time format in string". Could this be a conflict with locale/language settings? > > Thank you for hints. > Theo. > > The following code should illustrate for testing purpose. > > ### plot as a function of weekday > # generate some random test data > set print $BirthData > do for [i=1:100] { > RandomDate = rand(0)*1.5e9 > RandomNumber = rand(0)*100 > print(strftime("%a %d.%m.%Y %H:%M:%S", RandomDate)." ".sprintf("%g",RandomNumber)) > } > set print > print $BirthData > > set multiplot layout 3,1 > > set xdata time > set format x "%Y" > plot $BirthData u (timecolumn(2,"%d.%m.%Y")):4 > > set format x "%H:%M" > plot $BirthData u (timecolumn(3,"%H:%M")):4 > > set format x "%a" > plot $BirthData u (timecolumn(1,"%a")):4 # does not work! "warning: Bad time format in string" > > unset multiplot > ### end of code > > > > > > > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info |
|
From: theozh <th...@gm...> - 2018-10-13 22:21:05
|
Thank you for your comments. @John > Does this help? > https://stackoverflow.com/questions/17791828/gnuplot-date-time-in-x-axis No, not helpful in my case. @Alan well, in my 5.2 manual there is %U and %w but no %u. I'm not sure if it can be used for what I want to achieve. My current solution looks like the following (see example below). If it can be done simpler, I would be happy to learn about it. Disadvantage: I have to set xtics manually and don't see how to set mxtics. ### plot as a function of weekday reset $BirthData <<EOD # "%a" "%d.%m.%Y" "%H:%M:%S" "SomeValue" "time in s from 1.1.1970" Mon 13.02.1922 12:34:34 85.3 -1511004326.0 Tue 15.5.1962 04:12:18 73.1 -240868062.0 Wed 11.08.1948 09:12:56 97.3 -675010024.0 Thu 01.01.1970 00:00:00 32.7 0.0 Fri 31.12.1999 09:09:09 5.3 946631349.0 Sat 13.10.2018 18:45:01 45.2 1539456301.0 Sun 15.5.1966 04:12:18 17.4 -114637662.0 EOD set multiplot layout 2,1 set xdata time set format x "%Y" plot $BirthData u (timecolumn(2,"%d.%m.%Y")):4 lt 6 lc rgb "blue" # define formula Weekdaytime(t) = (floor(t/86400. + 3.)%7 + 7)%7 + t/86400. - floor(t/86400.) # 86400 seconds per day # 0=Mon, 1=Tue, 2=Wed, 3=Thu, 4=Fri, 5=Sat, 6=Sun # (... %7+7)%7 to account for negative time before 1.1.1970 # add 3 days because time=0 is 1.1.1970 and was a Thursday set xdata set format "%g" set xrange[0:7] set xtics ("Mon" 0, "Tue" 1, "Wed" 2, "Thu" 3, "Fri" 4, "Sat" 5, "Sun" 6) plot $BirthData u (Weekdaytime(timecolumn(2,"%d.%m.%Y %H:%M:%S"))):4 lt 6 lc rgb "red" not unset multiplot ### end of code |