[R] Alternatives to image(...) and filled.contour(...) for 2-D filled Plots
Jason Rupert
jasonkrupert at yahoo.com
Sun Nov 21 15:04:01 CET 2010
By any chance are there any alternatives to image(...) and filled.contour(...)
I used Rseek to search for that very topic, but didn't turn over any leads...
http://www.rseek.org/?cx=010923144343702598753%3Aboaz1reyxd4&newwindow=1&q=alternative+to+image+and+filled.contour&sa=Search&cof=FORID%3A11&siteurl=www.rseek.org%252F#1238
I'm sure there are some out there, but curious about some of the favorites and
ones folks have had success using.
Thanks for any insights and feedback.
I would like to use the alternative 2-D fill function with the example I have
been messing with in place of image(...) or filled.contour(...):
library(akima)
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)
temp_samples<-cbind(x_distance_val, y_distance_val, temperature_vals)
temp_samples_DF<-data.frame(x = x_distance_val, y = y_distance_val, z =
temperature_vals)
ak.fan <- interp(temp_samples[,1], temp_samples[,2], temp_samples[,3] )
length_val<-floor(max(temperature_vals) - min(temperature_vals))*2
color_vals_red_to_yellow_to_green<-colorRampPalette(c("red", "yellow", "green"),
space="Lab")(length_val)
color_vals_green_to_yellow_to_red<-colorRampPalette(c("green", "yellow", "red"),
space="Lab")(length_val)
plot(1,1, col = 0, xlim = c(min(x_distance_val), max(x_distance_val)), ylim =
c(min(y_distance_val), max(y_distance_val)), xlab = "Room X Position (FT)", ylab
= "Room Y Position (FT)", main = "Room Temp vs Position")
grid()
# filled.contour(ak.fan, col = color_vals_red_to_yellow_to_green)
# filled.contour(ak.fan, col = color_vals_green_to_yellow_to_red)
# image(ak.fan, col = color_vals_red_to_yellow_to_green, add = TRUE)
image(ak.fan, col = color_vals_green_to_yellow_to_red, add = TRUE)
More information about the R-help
mailing list