You probably already knew that you can draw mathematical equations in Google by typing the equation into the search box. For example, here's the Standard Normal density function:
I can't find a way to embed the graph directly, but if you click on it you'll find it's interactive: you can inspect points, zoom in/out etc. You can create a similar chart in R quite easily with the command:
(This works because there is a method for objects of type "function" -- like dnorm -- for the generic plot function.) It's not quite so eay to visualize of a function of two arguments in R, but Google has just announced a new capability for graphing bivariate equations as a 3-D surface. For example:
If you have a touchpad, the chart reacts to swiping gestures to allow you to rotate and inspect the surface. Play around with other bivariate equations in the search box to see what you can draw!
Google Inside Search: Graphing on Google.com - Now in 3D
They're using WebGL for the rendering, at least in my browser. I've recently added WebGL output to the rgl package in R, and am finding that it's not working in a lot of browsers. Does Google's display work in older browsers?
Click on my name for a sample from R.
Posted by: Duncan Murdoch | April 02, 2012 at 08:19
That's very cool Duncan - thanks for letting us know about rgl. On my MacOS X Lion MBPro, the image is dynamic in an up-to-date version of Firefox, but not in Safari or Chrome (my usual browser). Any idea how to enable it in those browsers?
Posted by: David Smith | April 02, 2012 at 09:49
This page
http://www.khronos.org/webgl/wiki/Getting_a_WebGL_Implementation
gives some information on both Safari and Chrome. I did get it working in Safari on my Mac; I forget what I did though. I haven't tried Chrome.
I just tried the Google page in IE 9, and didn't get the nice display, just message saying to use a browser that supports WebGL.
Posted by: Duncan Murdoch | April 02, 2012 at 11:09
Following up on the rgl thread, how about
library(emdbook)
curve3d(sqrt(x^2+y^2)+3*cos(sqrt(x^2+y^2))+5,
xlim=c(-20,20),
ylim=c(-20,20),
sys3d="rgl",col="blue")
?
?
Posted by: Ben Bolker | April 03, 2012 at 17:20
Hi Ben. I replaced the image attached to my signature with yours.
The problem with that approach is that it's not really a function you're plotting, it's a surface with fixed dimensions. If you come along later and add a point at x=30, y=30 the surface won't expand to that location. That's okay for Google, because the Google image can't be edited, but I'd like something better in rgl.
Posted by: Duncan Murdoch | April 04, 2012 at 17:34
Thank you, Duncan, for that link to WebGL enabled R! (Or maybe it is rgl? Or written from rgl by writeWebGL?)
I am running Windows 7 on a PC, with Chrome browser. With Javascript enabled, I was able to view your cute green 3-D topological thingy in full WebGL rotational glory! It worked just fine with the current (stable) release of Chrome, which is 18.0.1025.142. I didn't try IE 9 yet, but I have my doubts about that.
I've tried using this WebGL (showcase) tool https://github.com/notlion/streetview-stereographic
Stereographic Street View with IE 9, without success, though it works in Chrome browser.
Posted by: Ellie Kesselman | April 09, 2012 at 16:03
It's all of the above: writeWebGL is an R function in the rgl package.
I've now pushed it out to CRAN, so you can play with your own examples. Try example(writeWebGL), or make your own 3d scene and use writeWebGL to put it on a web page. Comments are welcome.
Posted by: Duncan Murdoch | April 12, 2012 at 17:55