Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Gnuplot 4.6 : problem with my X axis Post 303045997 by Tim2424 on Tuesday 21st of April 2020 09:27:38 AM
Old 04-21-2020
Gnuplot 4.6 : problem with my X axis

Hello, I need your help !



I've this data :

Code:
2020-04;26.94
2020-05;26.92
2020-06;26.89
2020-07;27.01
2020-08;26.73
2020-09;26.72

I use this gnuplot script ( I'm bound to use the 4.6 version of Gnuplot ) :

Code:
reset

FILE = "LINEARFIT.txt"
set datafile separator ";"
set xdata time
set timefmt "%Y-%d"
set format x "%Y\n%d"

plot FILE u (StartDate=timecolumn(1)):0 index 0 every ::0:0:0

EndDate = strptime("%Y-%d","2020-20")
f(x) = a*(x-StartDate) + b
FIT_LIMIT = 1e-8
fit f(x) FILE u (timecolumn(1)):2 via a,b

set terminal png truecolor size 900,520 background rgb "#eff1f0"
set output "/xxx/xxx/xxx/xxx.png"
set xrange[StartDate:EndDate]
set grid xtics, ytics
set yrange[0:30]
set format y "%g"
myLabel(n) = sprintf("%g",n)

plot FILE u (timecolumn(1)):2 w lp pt 7 lc rgb "red" notitle, \
'' using 1:2:(myLabel($2)) w labels offset 0,-0.5 notitle, \
      f(x) ti "linear fit with extrapolation"

And the output is :
Image

Can you tell me why, on the x axe, the values are displayed "Two by two" : 2020-04, 2020-06, 2020-08, 2020-10, 2020-12, 2020-14, 2020-16, 2020-18, 2020-20... While I want 2020-04, 2020-05, 2020-07, 2020-08, 2020-09, 2020-10, 2020-11 ,2020-12 ....

Could you help me ?

Thanks !
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with gnuplot

Hi, I am a beginner using UNIX, and was wondering how to use gnuplot from UNIX on my pc. I am connected remotely to my work's UNIX server using Secure Shell Client, and gnuplot won't open a new window when I use the plot command. How do I do this? Moreover, is it possible to save things from the... (0 Replies)
Discussion started by: KTTFB64
0 Replies

2. AIX

Add printer connected to a axis printserver

Hi guys, I have a AIX 4.3 system, and I need to configure a printer, but that printer it's connected to a axis print server. I have lot of years working with unix, but never added a printer in a AIX system. I need to add using "remote print queue", and add the hostname and ip to the /etc/hosts?... (2 Replies)
Discussion started by: uadm26
2 Replies

3. OS X (Apple)

Adjust X & Y screen axis

I'm using my wife's Macbook, and I just noticed that her screen is off axis, but I can't find a way to adjust it. I've tried playing around with resolution in preferences, but nothing. Maybe a terminal command for adjusting the x and y values of the screen? Any and all suggestions welcomed :) (2 Replies)
Discussion started by: andou
2 Replies

4. UNIX and Linux Applications

GNUplot

Hi, I am trying to make a plot of an ASCII file using GNUplot, but I keep getting error msg: for example plot filename.txt It says that (.txt ) is not identified ... I tried to write it without the .txt part, but I also get the error msg. Any idea why? :confused: (1 Reply)
Discussion started by: cosmologist
1 Replies

5. Shell Programming and Scripting

xargs and gnuplot

Hi All, Seems I have an xargs stdin problem that I don't understand. I have a script (call it myscript.sh) that takes the names of one or more file(s) specified on the command line and creates a single gnuplot command file containing multiple records, one for each specified file. Each of... (9 Replies)
Discussion started by: paulianna2002
9 Replies

6. UNIX for Dummies Questions & Answers

GNUPLOT problem

Hi, Im trying to plot a time series with gnuplot. this is my script set xdata time set yrange set timefmt "%H" set xrange set format x "%H:%M:%S" plot "time_vs_times.txt" using 1:2 title 'Interarrival time' with points lw 2 and this is my data 11:14:18 5 11:14:19 10... (10 Replies)
Discussion started by: jamie_123
10 Replies

7. Shell Programming and Scripting

Transposing X and Y axis of CSV data

Hello list, I have a source CSV data file as follows: PC_NAME,MS11-040,MS11-039,MS11-038,MS11-035 abc123,Not Applicable,Not Applicable,Not Applicable,Not Applicable abc987,Not Applicable,Not Applicable,Not Applicable,Not Applicable tnt999,Not Applicable,Not Applicable,Applicable,Not... (2 Replies)
Discussion started by: landossa
2 Replies

8. Shell Programming and Scripting

Problem creating graph with gnuplot with time on x-axis

Let me start by saying I'm new to gnuplot and not very good at unix at all.. Anyway, I'm each minute measuring temperature and humidity and saves the last 60 readings along with time in a textfile, values_minute. The contents of the file is formatted like this: time temperature humidity ... (8 Replies)
Discussion started by: hakro807
8 Replies

9. Shell Programming and Scripting

Gnuplot 3d binning

Hello I have a text file with tens of thousands of rows The format is x y where both x and y can be anything between -100 and +100. What I would like to do is have a 3d gnuplot where there are 10,000 squared or bins and each bin will count how many rows have a value that would be... (1 Reply)
Discussion started by: garethsays
1 Replies
Perl6::Slurp(3pm)					User Contributed Perl Documentation					 Perl6::Slurp(3pm)

NAME
Perl6::Slurp - Implements the Perl 6 'slurp' built-in SYNOPSIS
use Perl6::Slurp; # Slurp a file by name... $file_contents = slurp 'filename'; $file_contents = slurp '<filename'; $file_contents = slurp '<', 'filename'; $file_contents = slurp '+<', 'filename'; # Slurp a file via an (already open!) handle... $file_contents = slurp *STDIN; $file_contents = slurp $filehandle; $file_contents = slurp IO::File->new('filename'); # Slurp a string... $str_contents = slurp $string; $str_contents = slurp '<', $string; # Slurp a pipe... $str_contents = slurp 'tail -20 $filename |'; $str_contents = slurp '-|', 'tail', -20, $filename; # Slurp with no source slurps from whatever $_ indicates... for (@files) { $contents .= slurp; } # ...or from the entire ARGV list, if $_ is undefined... $_ = undef; $ARGV_contents = slurp; # Specify I/O layers as part of mode... $file_contents = slurp '<:raw', $file; $file_contents = slurp '<:utf8', $file; $file_contents = slurp '<:raw :utf8', $file; # Specify I/O layers as separate options... $file_contents = slurp $file, {raw=>1}; $file_contents = slurp $file, {utf8=>1}; $file_contents = slurp $file, {raw=>1}, {utf8=>1}; $file_contents = slurp $file, [raw=>1, utf8=>1]; # Specify input record separator... $file_contents = slurp $file, {irs=>" "}; $file_contents = slurp '<', $file, {irs=>" "}; $file_contents = slurp {irs=>" "}, $file; # Input record separator can be regex... $file_contents = slurp $file, {irs=>qr/ +/}; $file_contents = slurp '<', $file, {irs=>qr/ +| {2,}}; # Specify autochomping... $file_contents = slurp $file, {chomp=>1}; $file_contents = slurp {chomp=>1}, $file; $file_contents = slurp $file, {chomp=>1, irs=>" "}; $file_contents = slurp $file, {chomp=>1, irs=>qr/ +/}; # Specify autochomping that replaces irs # with another string... $file_contents = slurp $file, {irs=>" ", chomp=>" "}; $file_contents = slurp $file, {chomp=>" "}, {irs=>qr/ +/}; # Specify autochomping that replaces # irs with a dynamically computed string... my $n = 1; $file_contents = slurp $file, {chomp=>sub{ " #line ".$n++." "}; # Slurp in a list context... @lines = slurp 'filename'; @lines = slurp $filehandle; @lines = slurp $string; @lines = slurp '<:utf8', 'filename', {irs=>"x{2020}", chomp=>" "}; DESCRIPTION
"slurp" takes: o a filename, o a filehandle, o a typeglob reference, o an IO::File object, or o a scalar reference, converts it to an input stream if necessary, and reads in the entire stream. If "slurp" fails to set up or read the stream, it throws an exception. If no data source is specified "slurp" uses the value of $_ as the source. If $_ is undefined, "slurp" uses the @ARGV list, and magically slurps the contents of all the sources listed in @ARGV. Note that the same magic is also applied if you explicitly slurp <*ARGV>, so the following three input operations: $contents = join "", <ARGV>; $contents = slurp *ARGV; $/ = undef; $contents = slurp; are identical in effect. In a scalar context "slurp" returns the stream contents as a single string. If the stream is at EOF, it returns an empty string. In a list context, it splits the contents after the appropriate input record separator and returns the resulting list of strings. You can set the input record separator ("{ irs => $your_irs_here}") for the input operation. The separator can be specified as a string or a regex. Note that an explicit input record separator has no effect in a scalar context, since "slurp" always reads in everything anyway. In a list context, changing the separator can change how the input is broken up within the list that is returned. If an input record separator is not explicitly specified, "slurp" defaults to " " (not to the current value of $/ X since Perl 6 doesn't have a $/); You can also tell "slurp" to automagically "chomp" the input as it is read in, by specifying: ("{ chomp => 1 }") Better still, you can tell "slurp" to automagically "chomp" the input and replace what it chomps with another string, by specifying: ("{ chomp => "another string" }") You can also tell "slurp" to compute the replacement string on-the-fly by specifying a subroutine as the "chomp" value: ("{ chomp => sub{...} }"). This subroutine is passed the string being chomped off, so for example you could squeeze single newlines to a single space and multiple conseqcutive newlines to a two newlines with: sub squeeze { my ($removed) = @_; if ($removed =~ tr/ / / == 1) { return " " } else { return " "; } } print slurp(*DATA, {irs=>qr/[ ]* +/, chomp=>&squeeze}), " "; Which would transform: This is the first paragraph This is the second paragraph This, the third This one is the very last to: This is the first paragraph This is the second paragraph This, the third This one is the very last Autochomping works in both scalar and list contexts. In scalar contexts every instance of the input record separator will be removed (or replaced) within the returned string. In list context, each list item returned with its terminating separator removed (or replaced). You can specify I/O layers, either using the Perl 5 notation: slurp "<:layer1 :layer2 :etc", $filename; or as an array of options: slurp $filename, [layer1=>1, layer2=>1, etc=>1]; slurp [layer1=>1, layer2=>1, etc=>1], $filename; or as individual options (each of which must be in a separate hash): slurp $filename, {layer1=>1}, {layer2=>1}, {etc=>1}; slurp {layer1=>1}, {layer2=>1}, {etc=>1}, $filename; (...which, of course, would look much cooler in Perl 6: # Perl 6 only :-( slurp $filename, :layer1 :layer2 :etc; slurp :layer1 :layer2 :etc, $filename; ) A common mistake is to put all the options together in one hash: slurp $filename, {layer1=>1, layer2=>1, etc=>1}; This is almost always a disaster, since the order of I/O layers is usually critical, and placing them all in one hash effectively randomizes that order. Use an array instead: slurp $filename, [layer1=>1, layer2=>1, etc=>1]; WARNING
The syntax and semantics of Perl 6 is still being finalized and consequently is at any time subject to change. That means the same caveat applies to this module. DEPENDENCIES
Requires: Perl 5.8.0, Perl6::Export AUTHOR
Damian Conway (damian@conway.org) COPYRIGHT
Copyright (c) 2003-2012, Damian Conway. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.14.2 2012-06-14 Perl6::Slurp(3pm)
All times are GMT -4. The time now is 02:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy