Gnuplot Scripts

Posted on
Mon Jul 13, 2015 11:21 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Gnuplot Scripts

plot source using 1:2 with points pointtype 7 lw 2.0 lc rgb "#FF0000"

should look like:

plot source using ((360-$1+90)%360):2 with points pointtype 7 lw 2.0 lc rgb "#FF0000"

Posted on
Mon Jul 13, 2015 11:44 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Gnuplot Scripts

Dave,

try
unset raxis
to not create the "x"-axis

Posted on
Tue Jul 14, 2015 6:19 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

Thanks Karl!

The conversion formula works great. I've added it to the Python script that I use to generate the flat file I use for plotting. Works perfectly.

I've tried 'unset raxis' but it wants to hide everything. Maybe that's an order thing. I'll keep experimenting.

Thanks again!
Dave

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

[My Plugins] - [My Forums]

Posted on
Tue Jul 14, 2015 10:19 am
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Gnuplot Scripts

what do you want to keep? the grid and numbers I suppose?

you could add the numbers manually like you did for the coordinates

May I also suggest to use log scale for wind to capture high wind situations.

there the positioning is a bit tricky:

the x/y coordinates should be
if you choose : rrange=[0.1:100]

import math
dist= (math.log10(100*1.1) -math.log10(0.1)
multiply with 1.1 to move the numbers outside of the ring



for the East label:
set label "E" at +dist,+00.0 center tc rgb "#FFFFFF"

Posted on
Tue Jul 14, 2015 2:22 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Gnuplot Scripts

With gnuplot 5.0 patch level 1 last modified 2015-06-07

with radian or degree active I get a "Segmentation fault: 11"

when I remove either
"unset ytics"
or
"unset xtics"
it works

Code: Select all
set datafile separator ";"
set output 'out.png'   
set terminal png truecolor enhanced   medium  size 350,350 dashlength 0.5     background rgb "#FFFFFF"

set key textcolor rgb "#000000"
unset xlabel
unset ylabel
unset ytics   ## disable this then ok
unset xtics   ## disable this then ok
unset border
set polar

set angles degree
grids= 30

#set angles radian
#grids= 3.141/4.

set clip
set style line 100 lt 1 lw 1 linecolor rgb "#000000"
set grid polar grids back ls 100
set format r "%3.0f"
set rtics (1,5,50)
set logscale r
set rrange [0.1:50]   
plot 'test2'   using 1:2 with points pointtype 7 lw 0.5 lc rgb "#FF0000"  title ""   
file test2 is
2; 3


could some test this with gnuplot 5.0 patch level 1

with 4.6 it works fine.

Karl
Attachments
out.png
out.png (18.92 KiB) Viewed 6398 times

Posted on
Tue Jul 14, 2015 4:37 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Gnuplot Scripts

for those that want to upgrade to gnuplot 5.x:


only for polar plots:
in version 5.0.0 I get the screwy gridlines if i use lt =0, with lt=1 it all works. (lt=linetype)
in version 5.0.1 it crashes completely with some parameters (i.e. unset xticks)

I guess its always good to wait for version x.1

Karl

Posted on
Tue Jul 14, 2015 4:52 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Gnuplot Scripts

the screwy gridlines are actually shown on the gnuplot example site!

http://www.gnuplot.info/demo/poldat.html

I guess THATS a bug!!
Attachments
Screen Shot 2015-07-14 at 5.49.53 PM.png
Screen Shot 2015-07-14 at 5.49.53 PM.png (17.34 KiB) Viewed 6385 times

Posted on
Tue Jul 14, 2015 5:39 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Gnuplot Scripts

Averaging wind degrees and directions using vector averages:
Code: Select all
def averageDirectionRadius(rPhiList,degreeORreadian="deg"):
   import math
## calculates a vector average of a list of [r,phi] pairs
##  call: averageDirectionRadius([[5,0.3],[1,2]])  ## if you use radian do ([[5,0.3],[1,2]],degreeORreadian="pi")
## returns a proper vector average (R,PHI) of the r,phi pairs in rPhiList
## karl Wachs july 14, 2015
## use as you see fit.


   if degreeORreadian.upper().find("PI") ==-1:
      conv= math.pi/180.
   else:
      conv =1.

   if len(   rPhiList ) ==0:
      return 0,1

   phiAverage=0.
   rAverage=0.   
   xAv=0
   yAv=0
   for rPhiPair in rPhiList:
      if len(rPhiPair) !=2: continue  # this is an error ignore, user should add an error message
      if rPhiPair[0] ==0.: continue
      x = math.cos(rPhiPair[1]*conv)*rPhiPair[0]   
      y = math.sin(rPhiPair[1]*conv)*rPhiPair[0]
      xAv +=x
      yAv +=y
   R = math.sqrt(xAv*xAv+yAv*yAv)
   if R>0:
      phi = math.acos(xAv/R) / conv
      if yAv <0: phi*=-1.
   else:
      phi = 0
   return R, phi   



#test it:
print averageDirectionRadius([[1.,300.01],[1.,45]], degreeORreadian="deg")      
print averageDirectionRadius([[2.,300.01],[1.,45]], degreeORreadian="deg")      
print averageDirectionRadius([[1.,90.01],[1.,45]], degreeORreadian="deg")      
print averageDirectionRadius([[2.,90.01],[1.,45]], degreeORreadian="deg")      
print averageDirectionRadius([[2.,90.01],[1.,45]], degreeORreadian="deg")      
print averageDirectionRadius([[2.,90.01],[1.,45],[1.,45],[1.,45],[1.,45],[1.,45]], degreeORreadian="deg")      


if you want to use it in a plugin:

use:
Code: Select all
def averageDirectionRadius(self,rPhiList,degreeORreadian="deg")

print self.averageDirectionRadius([[1.,300.01],[1.,45]], degreeORreadian="deg"):


Karl

Posted on
Tue Jul 14, 2015 8:22 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

HI Karl - sorry. Busy day at work.

kw123 wrote:
what do you want to keep? the grid and numbers I suppose?


Grid and numbers for sure and I think I've found a compromise. Apparently, the tics inherit their color from the border. By setting the border to my grid color, and then unsetting the border, the tics retain the set color. It yields something halfway decent. Still tweaking to be done, but I can live with it until (if?) Gnuplot gives the ability to control tic color independently.

I'll post my work when I'm happy with it. :D
Dave

Code: Select all
set border linecolor "#444444"
unset border
Attachments
wind.png
wind.png (14.64 KiB) Viewed 6357 times

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

[My Plugins] - [My Forums]

Posted on
Tue Jul 14, 2015 8:29 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

kw123 wrote:
the screwy gridlines are actually shown on the gnuplot example site!


That's awesome!
Dave

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

[My Plugins] - [My Forums]

Posted on
Tue Jul 14, 2015 10:54 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Gnuplot Scripts

but I can live with it until (if?) Gnuplot gives the ability to control tic color independently.

you should start looking into MATPLOT. The learning curve is steep, but you can set anything you like.

Posted on
Wed Jul 15, 2015 3:31 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

kw123 wrote:
you should start looking into MATPLOT. The learning curve is steep, but you can set anything you like.

Thanks Karl -- I'll have a look!

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

[My Plugins] - [My Forums]

Posted on
Thu Jul 16, 2015 8:33 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

Still monkeying around, but starting to get a handle on it. I don't think I like showing so much (time series) data on one chart as it's tough to discern what's relevant.

The color represents speed. Also, it's a little hard to see here, but there is a white bar which shows the latest observation (hint: winds are NNW at 1 mph.)

Screen Shot 2015-07-16 at 9.24.45 PM.png
Screen Shot 2015-07-16 at 9.24.45 PM.png (28.77 KiB) Viewed 6311 times


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

reset
source = "/Users/.../Dropbox/Public/charts.csv"
windSource = "/Users/.../Dropbox/Public/wind.csv"

set datafile separator ","
set output '/Users/.../Dropbox/Public/wind.png'   
set terminal pngcairo truecolor enhanced size 300,300 font "Lato Light,11" dashlength 0.5 background rgb "#000000"

unset xtics
unset xlabel
unset ytics
unset ylabel
unset key

# Setting and unsetting the border to control tic color.
set border lc "#666666"
unset border

set angles degrees
set polar
set size square
set clip
set style line 100 lw 0.75 lc rgb "#444444"
set grid polar 45 back ls 100
set rrange [0:20]

set rtics (5,10,15,20) offset -1.5,1.5  font "Lato Light,8" tc rgb "#444444"

# Palette settings.
set palette maxcolors 4
set palette defined (5 "blue", 10 "green", 15 "yellow", 20 "red")
set cbrange [0:20]
unset colorbox

# Set margins to center the graph nicely.
set tmargin 2.5
set lmargin 5
set rmargin 5
set bmargin 2.5

# Set ordinal labels.
set label "N"  at +00.0,+21.5 center tc rgb "#FFFFFF"
set label "NE" at +16.0,+16.0 center tc rgb "#FFFFFF"
set label "E"  at +22.0,-00.5 center tc rgb "#FFFFFF"
set label "SE" at +16.0,-16.0 center tc rgb "#FFFFFF"
set label "S"  at +00.0,-22.5 center tc rgb "#FFFFFF"
set label "SW" at -16.5,-16.5 center tc rgb "#FFFFFF"
set label "W"  at -22.0,-00.5 center tc rgb "#FFFFFF"
set label "NW" at -16.0,+16.0 center tc rgb "#FFFFFF"

plot source u 25:26:26 w impulses lw 1 lc palette, \
     windSource u 2:3:3 w impulses lw 2 lc "#FFFFFF"   

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

[My Plugins] - [My Forums]

Posted on
Sat Jul 25, 2015 3:13 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gnuplot Scripts

I'm pretty happy with this. The lines represent observations over the last 2.5 hours--red as current, and then becoming darker as they get older. The scale automatically adjusts as needed. The ordinal labels are in Indigo (I removed them from the Gnuplot script.

Dave
Screen Shot 2015-07-25 at 4.02.38 PM.png
Screen Shot 2015-07-25 at 4.02.38 PM.png (31.56 KiB) Viewed 6276 times


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

reset
source = "/Users/.../Dropbox/Public/wind_chart_data/wind.csv"
set datafile separator ","
set output '/Users/.../Dropbox/Public/wind.png'   

set terminal pngcairo truecolor enhanced size 300,300 font "Lato Light,11" dashlength 0.5 background rgb "#000000"
stats source using 3 nooutput

unset xtics
unset xlabel
unset ytics
unset ylabel
unset key

# Setting and unsetting the border to control tic color.
set border linecolor "#666666"
unset border

set angles degrees
set polar
set size square
set clip
set style line 100 linewidth 0.75 linecolor rgb "#444444"
set grid polar 45 back linestyle 100
set style textbox opaque

# Set the max rrange to a nice "even" number.
range_factor = 5.0
max_range = STATS_max
if (max_range == 0) {max_range = 1}
max_range = ceil(abs(max_range) / range_factor) * range_factor
set rrange [0 : max_range]

# Setting dynamic tics and labeling depending on the value of data to be charted.
offset_x = -1.0
offset_y = 1.35
if (max_range <= 5.0) {set rtics (1, 2, 3, 4, 5) offset offset_x,offset_y font "Lato Light,8" textcolor rgb "#444444"}
if (max_range > 5.0) {set rtics (2, 4, 6, 8, 10) offset offset_x,offset_y font "Lato Light,8" textcolor rgb "#444444"}
if (max_range > 10.0) {set rtics (10, 20, 30, 40, 50) offset offset_x,offset_y font "Lato Light,8" textcolor rgb "#444444"}
if (max_range > 50.0) {set rtics (20, 40, 60, 80, 100) offset offset_x,offset_y font "Lato Light,8" textcolor rgb "#444444"}

if (STATS_max == 0.0) {set label "CALM" at 0.0,-2.5 center font "Lato Light,10" textcolor rgb "#FFFFFF" boxed}
if (STATS_max > 75.0) {set label "HOLY CRAP!" at +0.0,-2.5 center font "Lato Light,10" textcolor rgb "#FF0000" boxed}

# Plot the actual data.
plot '/Users/.../Dropbox/Public/wind_chart_data/wind_1.csv' using 2:3:3 with impulses linewidth 1 linecolor "#111111",\
     '/Users/.../Dropbox/Public/wind_chart_data/wind_2.csv' using 2:3:3 with impulses linewidth 1 linecolor "#222222",\
     '/Users/.../Dropbox/Public/wind_chart_data/wind_3.csv' using 2:3:3 with impulses linewidth 1 linecolor "#333333",\
     '/Users/.../Dropbox/Public/wind_chart_data/wind_4.csv' using 2:3:3 with impulses linewidth 1 linecolor "#444444",\
     '/Users/.../Dropbox/Public/wind_chart_data/wind_5.csv' using 2:3:3 with impulses linewidth 1 linecolor "#555555",\
     '/Users/.../Dropbox/Public/wind_chart_data/wind_6.csv' using 2:3:3 with impulses linewidth 1 linecolor "#666666",\
     '/Users/.../Dropbox/Public/wind_chart_data/wind_7.csv' using 2:3:3 with impulses linewidth 1 linecolor "#777777",\
     '/Users/.../Dropbox/Public/wind_chart_data/wind_8.csv' using 2:3:3 with impulses linewidth 1 linecolor "#888888",\
     '/Users/.../Dropbox/Public/wind_chart_data/wind_9.csv' using 2:3:3 with impulses linewidth 1 linecolor "#999999",\
     '/Users/.../Dropbox/Public/wind_chart_data/wind_10.csv' using 2:3:3 with impulses linewidth 3 linecolor "#FF0000"

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:32 am
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Gnuplot Scripts

For some reason this gnuplot script has stopped working. It still creates a .png file but the info isn't
updated.

Code: Select all
#! /usr/bin/env python2.6
# -*- coding: utf-8 -*-

import os.path
from os import system

csvFilePath = "/Users/TV/10DayForecast.csv"
dateTime    = str(indigo.server.getTime())

day1       = str(indigo.devices[379370551].states["d01_date"])
day2       = str(indigo.devices[379370551].states["d02_date"])
day3       = str(indigo.devices[379370551].states["d03_date"])
day4       = str(indigo.devices[379370551].states["d04_date"])
day5       = str(indigo.devices[379370551].states["d05_date"])
day6       = str(indigo.devices[379370551].states["d06_date"])
day7       = str(indigo.devices[379370551].states["d07_date"])
day8       = str(indigo.devices[379370551].states["d08_date"])
day9       = str(indigo.devices[379370551].states["d09_date"])
day10       = str(indigo.devices[379370551].states["d10_date"])
highTemp1       = str(int(indigo.devices[379370551].states["d01_high"]))
highTemp2       = str(int(indigo.devices[379370551].states["d02_high"]))
highTemp3       = str(int(indigo.devices[379370551].states["d03_high"]))
highTemp4       = str(int(indigo.devices[379370551].states["d04_high"]))
highTemp5       = str(int(indigo.devices[379370551].states["d05_high"]))
highTemp6       = str(int(indigo.devices[379370551].states["d06_high"]))
highTemp7       = str(int(indigo.devices[379370551].states["d07_high"]))
highTemp8       = str(int(indigo.devices[379370551].states["d08_high"]))
highTemp9       = str(int(indigo.devices[379370551].states["d09_high"]))
highTemp10       = str(int(indigo.devices[379370551].states["d10_high"]))
lowTemp1       = str(int(indigo.devices[379370551].states["d01_low"]))
lowTemp2       = str(int(indigo.devices[379370551].states["d02_low"]))
lowTemp3       = str(int(indigo.devices[379370551].states["d03_low"]))
lowTemp4       = str(int(indigo.devices[379370551].states["d04_low"]))
lowTemp5       = str(int(indigo.devices[379370551].states["d05_low"]))
lowTemp6       = str(int(indigo.devices[379370551].states["d06_low"]))
lowTemp7       = str(int(indigo.devices[379370551].states["d07_low"]))
lowTemp8       = str(int(indigo.devices[379370551].states["d08_low"]))
lowTemp9       = str(int(indigo.devices[379370551].states["d09_low"]))
lowTemp10       = str(int(indigo.devices[379370551].states["d10_low"]))
precip1       = str(indigo.devices[379370551].states["d01_pop"])
precip2       = str(indigo.devices[379370551].states["d02_pop"])
precip3       = str(indigo.devices[379370551].states["d03_pop"])
precip4       = str(indigo.devices[379370551].states["d04_pop"])
precip5       = str(indigo.devices[379370551].states["d05_pop"])
precip6       = str(indigo.devices[379370551].states["d06_pop"])
precip7       = str(indigo.devices[379370551].states["d07_pop"])
precip8       = str(indigo.devices[379370551].states["d08_pop"])
precip9       = str(indigo.devices[379370551].states["d09_pop"])
precip10       = str(indigo.devices[379370551].states["d10_pop"])

csvFile = open(csvFilePath, "w")
element = (day1 + "," + highTemp1 + "," + highTemp1 + "°," + lowTemp1 + "," + lowTemp1 + "°," + precip1 + "\n" +
         day2 + "," + highTemp2 + "," + highTemp2 + "°," + lowTemp2 + "," + lowTemp2 + "°," + precip2 + "\n" +         
         day3 + "," + highTemp3 + "," + highTemp3 + "°," + lowTemp3 + "," + lowTemp3 + "°," + precip3 + "\n" +
         day4 + "," + highTemp4 + "," + highTemp4 + "°," + lowTemp4 + "," + lowTemp4 + "°," + precip4 + "\n" +
         day5 + "," + highTemp5 + "," + highTemp5 + "°," + lowTemp5 + "," + lowTemp5 + "°," + precip5 + "\n" +
         day6 + "," + highTemp6 + "," + highTemp6 + "°," + lowTemp6 + "," + lowTemp6 + "°," + precip6 + "\n" +
         day7 + "," + highTemp7 + "," + highTemp7 + "°," + lowTemp7 + "," + lowTemp7 + "°," + precip7 + "\n" +
         day8 + "," + highTemp8 + "," + highTemp8 + "°," + lowTemp8 + "," + lowTemp8 + "°," + precip8 + "\n" +
         day9 + "," + highTemp9 + "," + highTemp9 + "°," + lowTemp9 + "," + lowTemp9 + "°," + precip9 + "\n" +
         day10 + "," + highTemp10 + "," + highTemp10 + "°," + lowTemp10 + "," + lowTemp10 + "°," + precip10)

csvFile.write(element)
csvFile.close()

system('/opt/local/bin/gnuplot /Library/Application\ Support/Perceptive\ Automation/Indigo\ 6/Scripts/10DayForecast.gp')


Any idea what may have changed?

Thanks,

Carl

Page 7 of 10 1 ... 4, 5, 6, 7, 8, 9, 10

Who is online

Users browsing this forum: No registered users and 2 guests