I have certain x and y coordinates for the position of an animal for a certain time t-max. I am using the code in R:
for (t in 1:tmax) {
plot(x[1:t],y[1:t]);
Sys.sleep(0.1);
}
to see how the animal is moving with time. So this shows me the path from each value of x to the subsequent value, till tmax. So now i have to present my findings in a Powerpoint presentation. so i was wondering if there is a method to insert this graph in a slide so that when i click a button, the graph is plotted and everybody can understand how the animal is moving.
Have a look on the Animation-Package on Cran:
http://cran.r-project.org/web/packages/animation/index.html
The animations package is cool, but i found it hard to learn. Instead of sleeping after each point is plotted, you could save the graph, and then use a video editor to merge the graphs into a movie clip. Windows movie maker will do this for you.
I'm not a big fan of animation, and in this case it doesn't seem useful. Why not just plot the graph, or if the path is seriously tangled, plot with a rainbow colormap applied to the line so you can easily follow from start to finish? See plotrix::color.scale.lines
Related
Link to sample image with tilting graph:
Link to NVD3 Streamgraph page:
The nvd3 streamgraph will descend or ascend sharply over time. I searched SO and the NVD3 documentation but didn't find a variable that controls where the zero of the y axis is at each point in time. Nor have I found discussions of this. In other words what makes the whole graph tilt in one direction or the other and how to control or turnoff this tilt.
I read a bit of the initial paper on streamgraphs by Byron but couldn't figure it out and thought I'd ask here.
Could someone please point me towards documentation on this or otherwise provide insight?
The NVD3 code for the stacked area chart accepts four possibilities for the chart style: stack, stream, stream-center, and expand. The default stream graph is the "stream" style, and this is the version that gets off-centre if you have any zero values in your data.
If you set the style explicitly to "stream-center", the chart behaves as expected. However, the radio buttons that switch between display styles switch back to the problematic algorithm, so they will need to be disabled.
chart.style('stream-center')
.showControls(false);
It's possible that the existence of this other display algorithm means that the NVD3 folks are working on it. The github issue page might be a good place to look for updates or responses from them:
https://github.com/novus/nvd3/issues/416
I have a code to plot a world map with a meteorological field for one moment (or one measure).
Is it possible to successively plot the map for different moments (for i from 1 to 125) in order to view a sort of video when we run the code?
Yes, look at the animation package.
It can creates an animated gif for you (as well as other tricks). There are live examples you can look at as eg Buffon's needle, a CLT demo and much more.
The package abstracts away some of the OS-dependent layers. If you know the basics, you can of course just call the corresponding tool from the imagemagick project which is likely to be available on OS of choice too.
I'm getting familiar with Graphviz and wonder if it's doable to generate a diagram/graph like the one below (not sure what you call it). If not, does anyone know what's a good open source framework that does it? (pref, C++, Java or Python).
According to Many Eyes, this is a bubble chart. They say:
It is especially useful for data sets with dozens to hundreds of values, or with values that differ by several orders of magnitude.
...
To see the exact value of a circle on the chart, move your mouse over it. If you are charting more than one dimension, use the menu to choose which dimension to show. If your data set has multiple numeric columns, you can choose which column to base the circle sizes on by using the menu at the bottom of the chart.
Thus, any presentation with a lot of bubbles in it (especially with many small bubbles) would have to be dynamic to respond to the mouse.
My usual practice with bubble charts is to show three or four variables (x, y and another variable through the size of the bubble, and perhaps another variable with the color or shading of the bubble). With animation, you can show development over time too - see GapMinder. FlowingData provides a good example with a tutorial on how to make static bubble charts in R.
In the example shown in the question, though, the bubbles appear to be located somewhat to have similar companies close together. Even then, the exact design criteria are unclear to me. For example, I'd have expected Volkswagen to be closer to General Motors than Pfizer is (if some measure of company similarity is used to place the bubbles), but that isn't so in this diagram.
You could use Graphviz to produce a static version of a bubble chart, but there would be quite a lot of work involved to do so. You would have to preprocess the data to calculate a similarity matrix, obtain edge weights from that matrix, assign colours and sizes to each bubble and then have the preprocessing script write the Graphviz file with all edges hidden and run the Graphviz file through neato to draw it.
I'd like to create a heat map in R that I want to use on a website. I stumbled upon the SVGAnnotation package which seems to be very nice to process SVG graphics in R to make them more interactive. First, I was planning to add tool tips for each cell in the heatmap - if the user hovers over the cell, the value of this cell should pop up. However, I am fighting with SVGAnnotation for more than 3 hours now, reading and trying things, and I can't get it to work.
I would appreciate any help on the SVGAnnotation tool tip function. But I would also very much appreciate alternatives to SVGAnnotation to add some activity to my R SVG heatmap.
So, what I have got so far looks like this:
library(SVGAnnotation)
data(mtcars)
cars <- as.matrix(mtcars)
map <- svgPlot(heatmap(cars))
addToolTips(map, ...) # problem
saveXML(map, "cars.svg")
My problem is the addToolTips function itself, I guess. Intuitively, I would simply insert the data matrix, i.e., cars, but this does not work and R gets stuck (it's calculating, but doesn't return anything, I waited 50 minutes)
EDIT:
After some more online research, I found a good example of what I want to achieve: http://online.wsj.com/article/SB125993225142676615.html#articleTabs=interactive
This heat map looks really great, and the interactive features (tool tips) work very well. I am wondering how they did that. To me, it looks like the graphic was done in R using the ggplot package.
I wrote a command line tool that can do exactly that if you are still interested to add tool tips to your heat map. It runs in Windows/Linux/MacOS terminals. All you need as input is the heat map as svg file and the data table/matrix that you used as input to create your heat map as csv or other text file.
I'm trying to use canvas to build a line graph between 2 date points. I need the date measurements along the bottom of the graph to change based on the start and end date data, which can vary widely between what information is grabbed by the application. Are there any plugins that do this, specifically/dynamically?
There is a huge abundance of chart and graph plotting libraries that can do this, and gRaphaël seems to do what you ask for quite well.