gnuplot do not take my variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting gnuplot do not take my variable
# 1  
Old 05-19-2012
gnuplot do not take my variable

Hi!

i want to print ot my data of the last seven days with gnuplot.
in a script i put my gnuplot-script and at the top i generate my date-variable.

Code:
  #/bin/bash -e
# Gnuplot script "API_Status.txt"
# set terminal postscript color landscape dl 2 lw 2 'Helvetica' 15 ;
# set output "status.eps"
# Variable - TIME
Z=7    # Zeitspanne
M=$`date +%m`
D=$`date +%d`
Ma=$`date --date="$Z days ago" +%m`
Da=$`date --date="$Z days ago" +%d`   
gnuplot -persist << EOF
#set terminal postscript eps color
set key off                             # 
#unset log                              # remove any log-scaling
#unset label                            # remove any previous labels
#set title "METE-Daten  - "
set xdata time
set timefmt "%m/%d/%y-%H%M%S"
set format x "%d.%m\n00:00"
set grid noxtics nomxtics ytics nomytics noztics nomztics \
 nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics
set xtics 86400                # x-Achsen-raster ein Tag in sec
set mxtics 4                # Aufteilung des Tages in 4 * 6h
set xrange [ "Ma/Da/12":"M/D/12" ]     # Zeitfenster festlegen
# set xlabel "Zeit (h)"

#Multiplot
#-----------------------
set multiplot
....

It give me the grafik, but over the complete month. My idea is, that
Code:
$`date --date="$Z days ago" +%m`

will not work properly. i tried allready to put it into brackets but without success. Maybe an alternetiv spefication of the time-variable?
Can someone help me?

Thanks in advance!
IMPe


Last edited by IMPe; 05-19-2012 at 02:45 PM..
# 2  
Old 05-19-2012
I could be wrong, but the last line looks problematic:

Quote:
Originally Posted by IMPe
Code:
M=$`date +%m`
D=$`date +%d`
Ma=$`date --date="$Z days ago" +%m`
Da=$`date --date="$Z days ago" +%d`
[...]
set xrange [ "Ma/Da/12":"M/D/12" ]

You create some variables (D, M, Da, Ma) but you never use them. Instead you use fixed strings ("D", "M", ...).

If you want to use a variables content (as opposed to its name) you have to prepend it with "$". To avoid ambiguity you can also enclose the variables name with curly braces ("{}"). So the last line should probably look like this:

Code:
set xrange [ "${Ma}/${Da}/12":"${M}/${D}/12" ]

Further, you should not use the backticks, even if they work. Backticks are an ancient construct and only supported for legacy purposes. Use the "$(...)" instead. That means change:

Code:
M=`date +%m`

to

Code:
M="$(date +%m)"

and accordingly with similar lines.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 3  
Old 05-19-2012
Quote:
Originally Posted by bakunin
I could be wrong, but the last line looks problematic:

If you want to use a variables content (as opposed to its name) you have to prepend it with "$". To avoid ambiguity you can also enclose the variables name with curly braces ("{}"). So the last line should probably look like this:

Code:
set xrange [ "${Ma}/${Da}/12":"${M}/${D}/12" ]

Further, you should not use the backticks, even if they work. Backticks are an ancient construct and only supported for legacy purposes. Use the "$(...)" instead. That means change:

Code:
M=`date +%m`

to

Code:
M="$(date +%m)"

and accordingly with similar lines.

I hope this helps.

bakunin
Thanks a lot - you dedect all my failures!
It helps a lot!

IMPe
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Gnuplot question

Hi! Let's say I have these two columns in file.txt 0 1 1 5 2 10 3 15 4 20 5 25 in gnuplot, i would plot usingplot 'file.txt' u 1:2 If I wanted to add a label to the y-axis I would useset label "Ef" at 0.0,7.0 However, I want the label Ef to be on the otherside of the y-axis. Not... (0 Replies)
Discussion started by: sidiq1983
0 Replies

3. Shell Programming and Scripting

Gnuplot command

My data input looks like this: -16.25 -38.75 9.69094 -16.25 -36.25 10.0594 -16.25 -33.75 10.3884 -16.25 -31.25 10.6653 -16.25 -28.75 10.7947 -16.25 -26.25 10.8838 -16.25 -23.75 10.8463 -16.25 -21.25 10.8131 -16.25 -18.75 10.7509 -16.25 -16.25 10.6581 -16.25 -13.75 10.6859 -16.25... (0 Replies)
Discussion started by: programmerc
0 Replies

4. Shell Programming and Scripting

Pass shell variable to gnuplot

Hi I am plotting a series of CDFs using gnuplot using plot "data" u 1:(1./x.) smooth cumulative I am doing this over many files and I need to tune the x value to the number of lines that meets a particular condition. Is it possible to get the line count from shell using cat file | grep... (7 Replies)
Discussion started by: jamie_123
7 Replies

5. UNIX and Linux Applications

gnuplot trouble

I am having a bit of trouble plotting a histogram in gnuplot. I am trying to use it to draw bars side by side. The first bar is from column five in my data file. The second bar is actually three bars stacked on top of each other and should be as tall as the first bar. The data is from the 2nd,... (0 Replies)
Discussion started by: kingnothing
0 Replies

6. UNIX for Dummies Questions & Answers

Need help! How to gnuplot a picture??

I would like to ask if I have already plot a graph using gnuplot, the setting(made by others) is in "gnuplot.defaults": gnuplot> load '<ParadisDir>/inputs/gnuplot.defaults' gnuplot> splot 'box.in' with lines, '0t0001' w lines How to transform it to bmp file? (or other types of pictures?) ... (2 Replies)
Discussion started by: kelvin490
2 Replies

7. 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

8. UNIX and Linux Applications

gnuplot + 3-d grids

When designing a 3-d graph in gnuplot, is it possible to create a 3-d grid that goes through each point on the graph ? (0 Replies)
Discussion started by: JamesGoh
0 Replies

9. 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
Login or Register to Ask a Question