Writedlm - adding a blank line every n lines

Hi,

I have three columns of numbers. x and y are coordinates and z is the value at x and y. I’m currently saving them to files like this:

open(path, "w") do io
    writedlm(io, [x y z])
end

I’m trying to splot as a pm3d map in gnuplot which needs a blank line for every change in the x value (see here).

I want to add blank lines and I assume it’s easier since my x value only changes every n lines throughout. What’s the most convenient way to do this?

Thanks

You may be interested in Gaston, a plotting package based on gnuplot.

I also use writedlm to output data for gnuplot. The relevant code starts here.

Sorry, this is not very flexible at the moment. Someone else wants to use gnuplot in a linux command line. Thanks for the help though. I’ll have a look.

open(path, "w") do io
	last=x[firstindex(x)]
	for index in eachindex(x)
		if last != x[index]
			writedlm(io," ")
		end
		writedlm(io, [x[index] y[index] z[index]])
		last=x[index]
	end
end

I interpret “convenient” as to be equal to easy or straight forward for today.

1 Like