R interactive plot?
How can a user interactively开发者_运维知识库 change one aspect (e.g., orientation or length of a line) on a 2D plot?
latticist and playwith are offering the interactive functionality for R's statistical plots.
For modifying specific details you can save the graph in SVG format and edit it in inkscape.
The rpanel package has worked for me.
library(rpanel)
lvm.draw <- function(panel) {
x=0:20
plot(x, panel$int + (panel$slo*x), ylim=panel$data, ylab="y", main="Adam's Super Duper Interactive Graph", typ="l", lwd=3, col="red")
grid()
panel
}
ylimdat<-c(-50,50)
panel <- rp.control(title = "Adam's Panel", data=ylimdat, slo=0.5, int=1.0, size=c(300, 160))
rp.slider(panel, var=slo, from=-5, to=5, action=lvm.draw, title="Slope", pos=c(5, 5, 290, 70), showvalue=TRUE)
rp.slider(panel, var=int, from=-50, to=50, action=lvm.draw, title="Intercept", pos=c(5, 70, 290, 90), showvalue=TRUE)
The tkexamp function in the TeachingDemos package helps you to create a graph with controls to change various options in the plot, there are several examples on the help page that can be run to see how it works.
The TkIdentify function in the same package allows you to drag labels (along with lines pointing from points to labels) to a desired position, you could start with the code from that function (all R, nothing compiled) as a basis for your own dynamic plot that would allow dragging a line.
精彩评论