Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No image written #20

Open
metal3d opened this issue Mar 20, 2018 · 6 comments
Open

No image written #20

metal3d opened this issue Mar 20, 2018 · 6 comments

Comments

@metal3d
Copy link

metal3d commented Mar 20, 2018

Hi again, ok so I tried with pure go 1.9 and checked if a simple test may work... And nothing is written. Maybe I'm doing something wring but, that's the test:

package main

import "github.com/Arafatk/glot"

func main() {
	dimensions := 2
	// The dimensions supported by the plot
	persist := false
	debug := true
	plot, _ := glot.NewPlot(dimensions, persist, debug)
	pointGroupName := "Simple Circles"
	style := "circle"
	points := [][]float64{{7, 3, 13, 5.6, 11.1}, {12, 13, 11, 1, 7}}
	// Adding a point group
	plot.AddPointGroup(pointGroupName, style, points)
	pointGroupName = "Simple Lines"
	style = "lines"
	points = [][]float64{{7, 3, 3, 5.6, 5.6, 7, 7, 9, 13, 13, 9, 9}, {10, 10, 4, 4, 5.4, 5.4, 4, 4, 4, 10, 10, 4}}
	plot.AddPointGroup(pointGroupName, style, points)
	// A plot type used to make points/ curves and customize and save them as an image.
	plot.SetTitle("Example Plot")
	// Optional: Setting the title of the plot
	plot.SetXLabel("X-Axis")
	plot.SetYLabel("Y-Axis")
	// Optional: Setting label for X and Y axis
	plot.SetXrange(-2, 18)
	plot.SetYrange(-2, 18)
	// Optional: Setting axis ranges
	plot.SavePlot("2.png")
}

Launching:

go run test.go
cmd> plot "/tmp/go-gnuplot-803798025" title "Simple Circles" with circle
res> 68
cmd> replot "/tmp/go-gnuplot-313721812" title "Simple Lines" with lines
res> 67
cmd> set title "Example Plot" 
res> 26
cmd> set xlabel 'X-Axis'
res> 20
cmd> set ylabel 'Y-Axis'
res> 20
cmd> set xrange [-2:18]
res> 19
cmd> set yrange [-2:18]
res> 19
cmd> set terminal png
res> 17
cmd> set output '2.png'
res> 19
cmd> replot  
res> 9
[patachou@patrice-desktop tensortest]$ ll 2.png
ls: impossible d'accéder à '2.png': No such file or directory

I'm trying to inderstand, I copy paste the all commands in gnuplot and it works... So what's the problem ?

@metal3d
Copy link
Author

metal3d commented Mar 20, 2018

It seems that now... It works with that patch, but I need to kill gnuplot after a while to let the command release and write png file. That's very strange...

diff --git a/common.go b/common.go
index e57bee1..f6bd9dd 100644
--- a/common.go
+++ b/common.go
@@ -176,10 +176,10 @@ func (plot *Plot) SavePlot(filename string) (err error) {
        }
        outputFormat := "set terminal " + plot.format
        plot.CheckedCmd(outputFormat)
-       outputFileCommand := "set output" + "'" + filename + "'"
+       outputFileCommand := "set output" + " '" + filename + "'"
        plot.CheckedCmd(outputFileCommand)
-       plot.CheckedCmd("replot  ")
-       return nil
+       plot.CheckedCmd("replot")
+       return
 }
 
 // SetFormat function is used to save the plot at this point.

But something strange appears... If I launch

@arafatkatze
Copy link
Owner

@metal3d I am incredibly sorry for the late reply.
I literally tested the example again and it works fine for me.
If you still face any issues then let me know.

@ali2210
Copy link

ali2210 commented Jan 25, 2020

Little improvement :
I like glot but when I had take a short
after ~20 sec my terminal response me without open gnuplot image.
please speedup glot it take ~20-30 sec on average to draw a graph

@arafatkatze
Copy link
Owner

arafatkatze commented Jan 25, 2020

@ali2210 I am sorry you found the software to be a bit slow.
I think it's probably because of the external dependencies of Glot.

So a lot of this has to be deeply ingrained into the software.

I am super busy with work these days but I would encourage you to try glot and see if you might find something interesting.

Thanks for the comment.

@ali2210
Copy link

ali2210 commented Jan 27, 2020 via email

@WyoMurf
Copy link

WyoMurf commented Jul 22, 2021

I'm having a problem with mapping 2 dimensional datasets; I'm using go1.16.2 linux/amd64;
In general, if I declare an array as:

var PointList [2][]float64

It will silently not plot. Perhaps I'm off-base here, but... ???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants