[R] Using image/contour with unevenly spaced data...
Jason Rupert
jasonkrupert at yahoo.com
Fri Nov 19 04:52:59 CET 2010
Is it possible to plot unevenly spaced data with image/contour function?
Below is an example of the type uneven data that I'm trying to plot with
image/contour functions. For example, I would like to have the x-distance on
the x-axis and y-distance on the y-axis and then the temperature values
determine the color used. Unfortunately this data was sampled such that it is
not evenly spaced on a Cartesian plot.
I was hoping that image(temp_samples) or contour(temp_samples) or something
similar would work, but my attempts didn't succeed.
Thanks for any feedback insights and hints...
hyp_distance<-seq(1,15)
angle_deg_val<-seq(0,15)
x_distance_val<-NULL
y_distance_val<-NULL
for(ii in 1:length(hyp_distance))
{
for(jj in 1:length(angle_deg_val))
{
x_distance_tmp<-hyp_distance[ii]*cos(angle_deg_val[jj]*pi/180)
y_distance_tmp<-hyp_distance[ii]*sin(angle_deg_val[jj]*pi/180)
x_distance_val<-c(x_distance_val, x_distance_tmp)
y_distance_val<-c(y_distance_val, y_distance_tmp)
}
}
temperature_vals<-rnorm(length(x_distance_val), 75, 2.2)
temp_samples<-cbind(x_distance_val, y_distance_val, temperature_vals)
More information about the R-help
mailing list