# Ruby Gnuplot Splot problem

**URL:** <https://www.ruby-forum.com/t/ruby-gnuplot-splot-problem/68200>\
**Category:** Ruby\
**Created:** [September 10, 2006, 11:46am UTC](https://www.ruby-forum.com/t/ruby-gnuplot-splot-problem/68200 "2006-09-10T11:46:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 10, 2006, 11:46am UTC](https://www.ruby-forum.com/t/ruby-gnuplot-splot-problem/68200/1 "2006-09-10T11:46:28Z")

</div>

Dear all,

I have a problem displaying three-dimensional plots using ruby-gnuplot.  
When I execute the code attached, a window opens up and displays  
axes and axes labelling, but the actual graph does not appear.  
It’s not a fault of my gnuplot installation, as two-dimensional graphs  
work out.  
I suspect something is wrong with the Dataset specification,  
but I don’t know what.

Thank you in advance.

Best regards,

Axel

* * *

$verbose=nil  
require “rubygems”  
require “gnuplot”  
include Math

Gnuplot.open do |gp|  
Gnuplot::SPlot.new( gp ) do |plot|

plot.ticslevel 0  
plot.pm3d ‘map’  
plot.palette ‘defined (-3 “blue”, 0 “white”, 1 “red”)’  
plot.xrange “[-10:10]”  
plot.yrange “[0:5]”  
plot.zrange “[-3:1]”

x\_min=-10.0  
x\_max=10.0  
y\_min=0.0  
y\_max=5.0  
x=[x\_min]  
y=[y\_min]  
steps=10  
for k in 0…steps  
x\<\<(x\_max-x\_min)/steps.to\_f  
end  
for k in 0…steps  
y\<\<(y\_max-y\_min)/steps.to\_f  
end  
z=[]  
x.each{|x\_v|  
temp=[]  
y.each{|y\_v|  
temp\<\<(2\*sin(x\_v)-1)\*exp(-y\_v)  
}  
z\<\<temp  
}  
plot.data \<\< Gnuplot::DataSet.new( [x,y,z] ) do |ds|  
ds.with = “pm3d”  
ds.notitle  
end  
end  
end
