Gnuplot Scripts

Posted on
Tue Sep 08, 2015 3:01 pm
ckeyes888 offline
Posts: 2354
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Gnuplot Scripts

Doh!...again. Restarted the plugin a second time and now it works fine.

Carl

Posted on
Tue Sep 08, 2015 7:34 pm
DaveL17 offline
User avatar
Posts: 6405
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

Glad you were able to get it working.

If this keeps happening for you, though, we should try to get to the bottom of what's causing the problem.

Dave

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

[My Plugins] - [My Forums]

Posted on
Tue Sep 08, 2015 10:34 pm
ckeyes888 offline
Posts: 2354
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Gnuplot Scripts

Thanks Dave. I did upgrade the Wunderground plugin as well.
Not sure what the hiccup was but it had been stable for months.

Carl

Posted on
Sun Oct 11, 2015 10:19 pm
TheTechnoPilot offline
Posts: 46
Joined: Mar 31, 2014
Location: Montreal, QC, Canada

Re: Gnuplot Scripts

Hi Dave,

I'm running into a weird issue with trying to use your code with GNUPlot, when I run it in terminal I get the following error...

Code: Select all
Seans-Mac-Pro-Server:Weather technopilot$ gnuplot 10dayPlot.gnu

set terminal pngcairo enhanced background "#000000" font "Lato-Light,9" linewidth 1 rounded size 600,200
             ^
"10dayPlot.gnu", line 6: unknown or ambiguous terminal type; type just 'set terminal' for a list

Here is the GNUPlot code of yours that I am trying to run...

Code: Select all
#! /usr/bin/env gnuplot
# -*- coding: utf-8 -*-

reset

set terminal pngcairo enhanced background "#000000" font "Lato-Light,9" linewidth 1 rounded size 600,200
set output "OSX/Users/technopilot/Dropbox/My\ Scripts/Indigo\ Automation/Weather/10dayForecast.png"
dataFileForecast = "OSX/Users/technopilot/Dropbox/My\ Scripts/Indigo\ Automation/Weather/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 label "32°" at graph 0.01,freezeLabel tc rgb "#FFFFFF" font ",8"

# Y2 Axis
set y2tics format "%2.0f%%" nomirror
set y2range [0:100]

plot dataFileForecast using 1:2 with lines,\
    dataFileForecast using 1:4 with lines,\
    freezeWarning with lines

Any ideas on getting past this? As part of problem solving I tried reinstalling GNUPlot using the ReInstall command in INDIGOplotD v3.11.8 with no luck and the same results.

Android's Tasker, to a person who does home automation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

Posted on
Sun Oct 11, 2015 11:34 pm
kw123 offline
User avatar
Posts: 8111
Joined: May 12, 2013
Location: Dallas, TX

Re: Gnuplot Scripts

open terminal and type
gnuplot
set terminal pngcairo

if you get an error message your terminal pngcairo is not setup

you can check with terminals are available with help terminal, then try them out with set terminal xxx


Karl

Posted on
Mon Oct 12, 2015 4:34 am
DaveL17 offline
User avatar
Posts: 6405
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

Yes, Karl's right. Here's my terminal list:

Code: Select all
Last login: Sun Oct 11 09:07:40 on console
computername:~ username$ gnuplot

   G N U P L O T
   Version 5.0 patchlevel 0    last modified 2015-01-01

   Copyright (C) 1986-1993, 1998, 2004, 2007-2015
   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> set terminal

Available terminal types:
             aqua  Interface to graphics terminal server for Mac OS X
             caca  Colour ascii art using libcaca, the Colour AsCii Art library
       cairolatex  LaTeX picture environment using graphicx package and Cairo backend
           canvas  HTML Canvas object
              cgm  Computer Graphics Metafile
          context  ConTeXt with MetaFun (for PDF documents)
            corel  EPS format for CorelDRAW
             dumb  ascii art for anything that prints text
              dxf  dxf-file for AutoCad (default size 120x80)
            eepic  EEPIC -- extended LaTeX picture environment
              emf  Enhanced Metafile format
            emtex  LaTeX picture environment with emTeX specials
         epscairo  eps terminal based on cairo
         epslatex  LaTeX picture environment using graphicx package
              fig  FIG graphics language for XFIG graphics editor
              gif  GIF images using libgd and TrueType fonts
             hpgl  HP7475 and relatives [number of pens] [eject]
             jpeg  JPEG images using libgd and TrueType fonts
            latex  LaTeX picture environment
              lua  Lua generic terminal driver
               mf  Metafont plotting standard
               mp  MetaPost plotting standard
             pcl5  HP Designjet 750C, HP Laserjet III/IV, etc. (many options)
         pdfcairo  pdf terminal based on cairo
              png  PNG images using libgd and TrueType fonts
         pngcairo  png terminal based on cairo
       postscript  PostScript graphics, including EPSF embedded files (*.eps)
          pslatex  LaTeX picture environment with PostScript \specials
            pstex  plain TeX with PostScript \specials
         pstricks  LaTeX picture environment with PSTricks macros
              qms  QMS/QUIC Laser printer (also Talaris 1200 and others)
              svg  W3C Scalable Vector Graphics
          tek40xx  Tektronix 4010 and others; most TEK emulators
          tek410x  Tektronix 4106, 4107, 4109 and 420X terminals
          texdraw  LaTeX texdraw environment
             tgif  TGIF X11 [mode] [x,y] [dashed] ["font" [fontsize]]
             tikz  TeX TikZ graphics macros via the lua script driver
         tkcanvas  Tk/Tcl canvas widget [perltk] [interactive]
             tpic  TPIC -- LaTeX picture environment with tpic \specials
          unknown  Unknown terminal type - not a plotting device
            vttek  VT-like tek40xx terminal emulator
              wxt  wxWidgets cross-platform windowed terminal
              x11  X11 Window System
             xlib  X11 Window System (gnulib_x11 dump)
            xterm  Xterm Tektronix 4014 Mode
gnuplot>

It's important to note that you can't (necessarily) just substitute another terminal type in the script, because it's common for terminal types to support different features, functions, and syntax.

Do you see pngcairo in your terminal list?
Dave

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

[My Plugins] - [My Forums]

Posted on
Sun Oct 18, 2015 2:10 pm
TheTechnoPilot offline
Posts: 46
Joined: Mar 31, 2014
Location: Montreal, QC, Canada

Re: Gnuplot Scripts

Hi Karl and Dave,

Sadly I don't have it...

Code: Select all
   G N U P L O T
   Version 5.0 patchlevel 1    last modified 2015-06-07

   Copyright (C) 1986-1993, 1998, 2004, 2007-2015
   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 'unknown'
gnuplot> set terminal pngcairo
Terminal type set to 'unknown'
                      ^
         unknown or ambiguous terminal type; type just 'set terminal' for a list

gnuplot> set terminal

Available terminal types:
           canvas  HTML Canvas object
              cgm  Computer Graphics Metafile
          context  ConTeXt with MetaFun (for PDF documents)
            corel  EPS format for CorelDRAW
             dumb  ascii art for anything that prints text
              dxf  dxf-file for AutoCad (default size 120x80)
            eepic  EEPIC -- extended LaTeX picture environment
              emf  Enhanced Metafile format
            emtex  LaTeX picture environment with emTeX specials
         epslatex  LaTeX picture environment using graphicx package
              fig  FIG graphics language for XFIG graphics editor
              gif  GIF images using libgd and TrueType fonts
             hpgl  HP7475 and relatives [number of pens] [eject]
             jpeg  JPEG images using libgd and TrueType fonts
            latex  LaTeX picture environment
              lua  Lua generic terminal driver
               mf  Metafont plotting standard
               mp  MetaPost plotting standard
             pcl5  HP Designjet 750C, HP Laserjet III/IV, etc. (many options)
              png  PNG images using libgd and TrueType fonts
       postscript  PostScript graphics, including EPSF embedded files (*.eps)
          pslatex  LaTeX picture environment with PostScript \specials
            pstex  plain TeX with PostScript \specials
         pstricks  LaTeX picture environment with PSTricks macros
              qms  QMS/QUIC Laser printer (also Talaris 1200 and others)
              svg  W3C Scalable Vector Graphics
          tek40xx  Tektronix 4010 and others; most TEK emulators
          tek410x  Tektronix 4106, 4107, 4109 and 420X terminals
          texdraw  LaTeX texdraw environment
             tgif  TGIF X11 [mode] [x,y] [dashed] ["font" [fontsize]]
             tikz  TeX TikZ graphics macros via the lua script driver
         tkcanvas  Tk/Tcl canvas widget [perltk] [interactive]
             tpic  TPIC -- LaTeX picture environment with tpic \specials
          unknown  Unknown terminal type - not a plotting device
            vttek  VT-like tek40xx terminal emulator
            xterm  Xterm Tektronix 4014 Mode
gnuplot>

Any suggestions on how to install it or set it up?

Sean

Android's Tasker, to a person who does home automation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

Posted on
Sun Oct 18, 2015 2:40 pm
kw123 offline
User avatar
Posts: 8111
Joined: May 12, 2013
Location: Dallas, TX

Re: Gnuplot Scripts

Just try png. It does 99% of what you likely need


Sent from my iPhone using Tapatalk

Posted on
Sun Oct 18, 2015 3:15 pm
kw123 offline
User avatar
Posts: 8111
Joined: May 12, 2013
Location: Dallas, TX

Re: Gnuplot Scripts

Code: Select all
set terminal png truecolor enhanced  medium  size 820,350 dashlength 0.5      background rgb "#FFFFFF"


will use a png terminal, in enhanced mode size= ... points, background= white and line dashes are 50% on / 50% off

Karl

Posted on
Sat Nov 07, 2015 5:54 am
DaveL17 offline
User avatar
Posts: 6405
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

With some help from Stack, I've come up with additional features to make my Gnuplot scripts even easier to manage. The idea is to have a centralized means of controlling graphing parameters, such that I can change them in one place and have them promulgate to all my charts. It's actually quite straightforward.

I maintain one file called "_gnuplotParms.txt" (it's named this way just so that it appears at the top of the folder.) Here's a very short example that shows values for background color and font style:
Code: Select all
# Background Color
#000000

# Chart Font Style
Lato-Light,9

Notice that there are no quotes around the values on lines 2 and 5. The quotes are added when the value's loaded. Then, within each charting file, I have added this to the start of the file:
Code: Select all
parmFile = "_gnuplotParms.txt"
backgroundColor_var = system(sprintf("sed -n '2p' %s", parmFile))
font_var = system(sprintf("sed -n '5p' %s", parmFile))

set terminal pngcairo enhanced background backgroundColor_var font font_var linewidth 1 rounded size 600,200

Note that '2p' and '5p' correspond to the line number of the settings file. Rinse and repeat for any value that you want to adjust centrally. Then, all I have to do is change the parameter value once in "_gnuplotParms.txt" and it will flow through to all of my charts. One important point: this operation will add double-quotes around the imported value, so if you need the value in numeric form, you'll have to adjust it locally after it's imported.

This method would allow for a certain manner of centralized scripting too--for example, you could have Indigo manage certain settings in the flat file based on criteria using a Python script to edit the parameters file directly. I think this opens up some pretty neat possibilities.
Dave

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

[My Plugins] - [My Forums]

Posted on
Sat Nov 07, 2015 6:12 am
DaveL17 offline
User avatar
Posts: 6405
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

UPDATE: There's an even easier solution!

_gnuplotParms.txt:
Code: Select all
backgroundColor_var = "#000000"
font_var = "Lato-Light,9"

Gnuplot file:
Code: Select all
Load "_gnuplotParms.txt"

set terminal pngcairo enhanced background backgroundColor_var font font_var linewidth 1 rounded size 600,200

The 'Load' command basically takes whatever is in the file and treats it as if it was typed directly into the terminal. This method also solves the double-quotes issue as well.

Dave

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

[My Plugins] - [My Forums]

Posted on
Sun Nov 08, 2015 6:08 am
DaveL17 offline
User avatar
Posts: 6405
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

An update to the update above. It's best to use the absolute path to the parameters files (rather than the relative path.) Depending on how you invoke Gnuplot script, a relative path may not work.

Do this:
Code: Select all
load "/Users/username/Dropbox/Indigo\ Scripts/_gnuplotParms.txt"

Not this:
Code: Select all
load "_gnuplotParms.txt"

Dave

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

[My Plugins] - [My Forums]

Posted on
Sat Jan 16, 2016 5:51 am
ckeyes888 offline
Posts: 2354
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Gnuplot Scripts

Could someone point me to the gnuplot install instructions? (10.6.8)

Thanks,

Carl

Posted on
Sat Jan 16, 2016 6:29 am
DaveL17 offline
User avatar
Posts: 6405
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

Hi Carl - what happened? You had Gnuplot installed before. Did you have to replace the server or something? In any event, try this from the terminal::

Code: Select all
brew install gnuplot

if you get an error, try this command from the terminal to see if you have homebrew installed:

Code: Select all
brew help

If you get an error here, try this command from the terminal to install homebrew:

Code: Select all
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

I believe that Gnuplot still requires X-Code Command Line Tools to be installed, so you may have to install that too.
Dave

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

[My Plugins] - [My Forums]

Posted on
Sat Jan 16, 2016 10:02 am
ckeyes888 offline
Posts: 2354
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Gnuplot Scripts

Yea, I'm attempting to get a bit more current with a new mini running 10.6.8.

Going pretty well so far but what I did before to get Xcode and Gnuplot installed
doesn't seem to be working. Appreciate the help...again!

Here's the terminal info:

Code: Select all
TV2:~ TV$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press RETURN to continue or any other key to abort
==> Downloading and installing Homebrew...
==> Installation successful!
==> Next steps
Run `brew help` to get started
TV2:~ TV$ brew install gnuplot
Warning: You are using OS X 10.6.
We (and Apple) do not provide support for this old version.
You may encounter build failures or other breakages.
==> Downloading https://downloads.sourceforge.net/project/gnuplot/gnuplot/5.0.1/
Already downloaded: /Library/Caches/Homebrew/gnuplot-5.0.1.tar.gz
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/gnuplot/5.0.1
==> make
Last 15 lines from /Users/TV/Library/Logs/Homebrew/gnuplot/02.make:
Making all in man
make[2]: Nothing to be done for `all'.
Making all in demo
Making all in plugin
gcc-4.0 -DHAVE_CONFIG_H -I. -I../..   -I/usr/local/opt/readline/include -I/usr/local/Cellar/gd/2.1.1/include -I/usr/local/Cellar/lua/5.2.4_2/include -rdynamic -fPIC -I../../src -g -O2 -c -o demo_plugin_so-demo_plugin.o `test -f 'demo_plugin.c' || echo './'`demo_plugin.c
gcc-4.0 -rdynamic -fPIC -I../../src -g -O2 -shared -L/usr/local/opt/readline/lib -L/usr/X11/lib -L/usr/local/opt/jpeg/lib -o demo_plugin.so demo_plugin_so-demo_plugin.o  -liconv
Undefined symbols:
  "_main", referenced from:
      start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [demo_plugin.so] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

READ THIS: https://git.io/brew-troubleshooting

Warning: You are using OS X 10.6.
We (and Apple) do not provide support for this old version.
You may encounter build failures or other breakages.
TV2:~ TV$ gnuplot
-bash: gnuplot: command not found
TV2:~ TV$


Still gnuplot command not found.

edit: Also maybe useful:
Code: Select all
TV2:~ TV$ gcc --version
i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

TV2:~ TV$ pkgutil --pkg-info=com.apple.pkg.DeveloperToolsCLI
No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
TV2:~ TV$


Thanks,

Carl

Who is online

Users browsing this forum: No registered users and 1 guest