Gnuplot Scripts

Posted on
Thu May 14, 2015 7:58 pm
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

ckeyes888 wrote:
Thanks Dave. I'll dive in and see what happens.

Carl

That's when the fun starts. Feel free to ask questions if you get stuck.

Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu May 14, 2015 8:06 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Gnuplot Scripts

Got the .csv create script working but having errors creating the .png.

Any idea why it won't compile?

Thanks,

Carl
Attachments
photo.JPG
photo.JPG (47.05 KiB) Viewed 5150 times

Posted on
Thu May 14, 2015 8:13 pm
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

ckeyes888 wrote:
Got the .csv create script working but having errors creating the .png.

Any idea why it won't compile?

Thanks,

Carl

That code is the Gnuplot code (not Python code). Rather than run that in Indigo, you need to run it with Gnuplot which is an entirely separate program. You need to install Gnuplot.

Perhaps the easiest way is to follow Karl's installation instructions for the Indigo plugin IndigoPlotD.

Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu May 14, 2015 9:03 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Gnuplot Scripts

Ok, I got gnuplot installed and tried pasting the code into terminal and got this:

Code: Select all
TV:~ TV$ gnuplot

   G N U P L O T
   Version 4.6 patchlevel 4    last modified 2013-10-06
   Build System: Darwin i386

   Copyright (C) 1986-1993, 1998, 2004, 2007-2013
   Thomas Williams, Colin Kelley and many others

   gnuplot home:     http://www.gnuplot.info
   faq, bugs, etc:   type "help FAQ"
   immediate help:   type "help"  (plot window: hit 'h')

Terminal type set to 'aqua'
gnuplot> #! /usr/bin/env gnuplot
gnuplot> reset
gnuplot>
gnuplot> set terminal pngcairo enhanced background "#000000" font "Lato-Light,9" linewidth 1 rounded size 600,200
Terminal type set to 'pngcairo'
set output "/Users/TV/10DayForecast.png"
dataFileForecast = "/Users/TV/10DayForecast.csv"
set datafile separator ','
set timefmt "%Y-%m-%d"
stats dataFileForecast using 2:4 nooutput

freezeWarning = 32.
Yhigh = STATS_max_x + 10.
Ylow = STATS_min_y - 10.
freezeLabel = ((freezeWarning-Ylow) / (Yhigh-Ylow))

unset key
set border linetype rgb "#666666"
set boxwidth 0.25 relative
set style fill transparent solid 0.4
set style line 1 linetype rgb "#0066CC"
set style line 2 linetype rgb "#FFFFFF" pointtype 7 pointsize .5
set style line 3 linetype rgb "#666666"
set style line 4 linetype rgb "#FFFF00"
set style line 5 linetype rgb "#333333"

set label "°" right

unset mxtics
set tics textcolor rgb "#666666"

# X Axis
set xdata time
set xtics format "%a" nomirror
set autoscale xfix
set offsets 12*60*60,12*60*60,0,0

# Y Axis
set ytics format "%2f°" nomirror
set yrange [Ylow:Yhigh]
unset ytics
if (32 > Ylow) set lif (32 > Ylow) set lif (32 > Ylow) set lif (32 > Ylow) set lif (32 > Options are ' background "#000000" enhanced font "Lato-Light,9" fontscale 1.0 size 600, 200  rounded'
gnuplot> set output "/Users/TV/10DayForecast.png"
gnuplot> dataFileForecast = "/Users/TV/10DayForecast.csv"
gnuplot> set datafile separator ','
gnuplot> set timefmt "%Y-%m-%d"
gnuplot> stats dataFileForecast using 2:4 nooutput
gnuplot>
gnuplot> freezeWarning = 32.
gnuplot> Yhigh = STATS_max_x + 10.
gnuplot> Ylow = STATS_min_y - 10.
gnuplot> freezeLabel = ((freezeWarning-Ylow) / (Yhigh-Ylow))
gnuplot>
gnuplot> unset key
gnuplot> set border linetype rgb "#666666"
gnuplot> set boxwidth 0.25 relative
gnuplot> set style fill transparent solid 0.4
gnuplot> set style line 1 linetype rgb "#0066CC"
gnuplot> set style line 2 linetype rgb "#FFFFFF" pointtype 7 pointsize .5
gnuplot> set style line 3 linetype rgb "#666666"
gnuplot> set style line 4 linetype rgb "#FFFF00"
gnuplot> set style line 5 linetype rgb "#333333"
gnuplot>
gnuplot> set label "°" right
gnuplot>
gnuplot> unset mxtics
gnuplot> set tics textcolor rgb "#666666"
gnuplot>
gnuplot> # X Axis
gnuplot> set xdata time
gnuplot> set xtics format "%a" nomirror
gnuplot> set autoscale xfix
gnuplot> set offsets 12*60*60,12*60*60,0,0
gnuplot>
gnuplot> # Y Axis
gnuplot> set ytics format "%2f°" nomirror
gnuplot> set yrange [Ylow:Yhigh]
gnuplot> unset ytics
gnuplot> if (32 > Ylow) set lif (32 > Ylow) set lif (32 > Ylow) set lif (32 > Ylow) set lif (32 > Ylow) sset y2tics format "%2.0f%%" nomirror
gnuplot> set y2range [0:100]
gnuplot>
gnuplot> plot dataFileForecast using 1:6 with impulses linestyle 4 axes x1y2,\
>    dataFileForecast using 1:2 with filledcurves above y1=0 linestyle 5 axes x1y1,\
>     dataFileForecast using 1:2 with points linestyle 2 axes x1y1,\
>     dataFileForecast using 1:2:3 with labels offset 1.75,0.5 textcolor "#FFFFFF" font ",8" axes x1y1,\
>    dataFileForecast using 1:4 with filledcurves above y1=0 linestyle 3 axes x1y1,\
>     dataFileForecast using 1:4 with points linestyle 2 axes x1y1,\
>     dataFileForecast using 1:4:5 with labels offset 1.75,0.5 textcolor "#FFFFFF" font ",8" axes x1y1,\
>     freezeWarning with filledcurve above y1=0 linestyle 1 axes x1y1
                                                                                                                                                                                                                                                                                                         ^
         colorspec option not recognized

gnuplot>     


No doubt that's not how it's done. How do you execute the gnuplot code to make the .png?

Thanks,

Carl

Posted on
Thu May 14, 2015 11:26 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Gnuplot Scripts

you should to put all gnuplot commands into a file lets say "a.gnu"
then in the directory in a terminal where a.gnu is you type:
gnuplot a.gnu


or
gnuplot pathtoa/a.gnu

Also it seems that the code is for gnuplot 5.x not 4.x

just looking it from 100 feet

Karl

Posted on
Fri May 15, 2015 4:31 am
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

Karl is right about gnuplot 5.0 for a start. It's not required to generate charts in general, there's just a few commands in my script example that require it. Second, if you look at the Python script earlier in this thread, you will see this line at the end:

Code: Select all
system('/opt/local/bin/gnuplot /Library/Application\ Support/Perceptive\ Automation/Indigo\ 6/Scripts/10DayForecast.gp')
The first part points to the gnuplot executable /opt/local/bin/gnuplot and the second part points to the gnuplot file /Library/Application\ Support/Perceptive\ Automation/Indigo\ 6/Scripts/10DayForecast.gp your files may be in a different location than mine.

So I'm running the command that Karl mentioned: gnuplot 10DayForecast.gp ....with the literal paths to the files stuck in front.

You are very close!
Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri May 15, 2015 5:00 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Gnuplot Scripts

Thanks, but I don't feel very close :-) Lost me in putting the commands into a file...a text file?

Carl

Posted on
Fri May 15, 2015 6:29 pm
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

ckeyes888 wrote:
Thanks, but I don't feel very close :-) Lost me in putting the commands into a file...a text file?

Carl

You *are* very close. :D

There are four files for my example:
10DayForecast.py
10DayForecast.gp
10DayForecast.csv
10DayForecast.png

The 10DayForecast.py file is the python file that generates the data file for charting. Look for a post earlier in this thread with a code block that starts: "#! /usr/bin/env python2.6" and save this code in a text file. I like to keep these files in the Indigo Scripts folder. This is the file that you link to in Indigo and run on a schedule. You'll need to change the paths in the file to point to your preferred locations.

The 10DayForecast.gp file is the Gnuplot file that generates the actual chart image file. Look for the first post in this thread with a code block that starts: #! /usr/bin/env gnuplot and save the code in a text file. I like to keep these files in the Indigo Scripts folder. This pretty much sits in the background and is what generates the chart.

The 10DayForecast.csv file is automatically generated by the Python script. This file contains the data that gets charted. Look in the Python script for the variable that sets the location for this file. The line is right near the top.

The 10DayForecast.png file is automatically generated by the Gnuplot script. This file is the one that you will link to on your control pages.

Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri May 15, 2015 7:45 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Gnuplot Scripts

Really appreciate all the help and the detailed overview. Still no joy on creating the png yet though.
To make the 10DayForecast.gp I just pasted the code into a TextEdit doc, saved as an rtf and
renamed to .gp. Seems odd, probably incorrect?

It was mentioned earlier that some of the code requires Gnuplot 5.0. I'm not seeing any errors in
the log when I run the python script but maybe that's a problem?

Edit: Tried making the .gp file in Text Wrangler and now it creates the .png but it has no data
and won't open :-(.

Thanks,

Carl

Posted on
Fri May 15, 2015 8:10 pm
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

Not a problem Carl.

Don't save it as an RTF file, but rather as plain text. When you make a new Textedit document and paste the code in, go to the menu and select "Format" and then "Make Plain Text". That should fix that issue.

You won't see any gnuplot errors in Indigo because you're running gnuplot outside Indigo itself. One way to see if the gnuplot part of the process is working correctly is to open a terminal window and then navigate to the folder where the script is located and then type gnuplot SCRIPTNAME.

Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri May 15, 2015 8:27 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Gnuplot Scripts

Ok, here's the return in Terminal.

TV:Users TV$ gnuplot 10DayForecast.gp

plot dataFileForecast using 1:6 with impulses linestyle 4 axes x1y2, dataFileForecast using 1:2 with filledcurves above y1=0 linestyle 5 axes x1y1, dataFileForecast using 1:2 with points linestyle 2 axes x1y1, dataFileForecast using 1:2:3 with labels offset 1.75,0.5 textcolor "#FFFFFF" font ",8" axes x1y1, dataFileForecast using 1:4 with filledcurves above y1=0 linestyle 3 axes x1y1, dataFileForecast using 1:4 with points linestyle 2 axes x1y1, dataFileForecast using 1:4:5 with labels offset 1.75,0.5 textcolor "#FFFFFF" font ",8" axes x1y1, freezeWarning with filledcurve above y1=0 linestyle 1 axes x1y1
^
"10DayForecast.gp", line 54: colorspec option not recognized

Maybe mod the script to accommodate the Gnuplot 4?

Thanks,

Carl

Posted on
Sat May 16, 2015 4:30 am
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

I'm not sure why that's balking to be honest. Let's try replacing the last line with this and see if it makes a difference.

Code: Select all
freezeWarning with filledcurves above y1=0 linestyle 1 axes x1y1

(note it says filledcurves and not filledcurve.)

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat May 16, 2015 9:56 am
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Gnuplot Scripts

Nuts, same result. The png is created but still has no data and won't open.

Thanks,

Carl

Posted on
Sat May 16, 2015 10:30 am
Korey offline
User avatar
Posts: 813
Joined: Jun 04, 2008
Location: Henderson, NV

Re: Gnuplot Scripts

Hey Dave!

Seems like this should a a new option from within your plug in! (Create Graphic) :mrgreen: :mrgreen:

--
Korey

Posted on
Sat May 16, 2015 2:40 pm
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

ckeyes888 wrote:
Nuts, same result. The png is created but still has no data and won't open.

Thanks,

Carl

THe fact that the PNG is created is a good sign.

Try this for me. Within the Gnuplot script, change all instances of "filledcurves above y1=0" with "lines". For example,

Code: Select all
freezeWarning with lines linestyle 1 axes x1y1

If that doesn't work, we'll take a look at your two script files.

Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Who is online

Users browsing this forum: No registered users and 1 guest

cron