I am preparing for the exams, and I have spent couple of days trying to solve the task, but without success. Can someone show me how I solve this? The result should look like this:
You can use StreamPlot or VectorPlot
for 3D fields, there is no built-in command. However, you can use VectorPlot3D.
There is also a 3rd party code for 3D streamline plot that you can find here.
Related
This idea has been spurred by this work at Five Thirty Eight.
I'm not entirely sure that they used R, but the chart appears in a similar fashion to their other data viz. I looked around here, but couldn't find anything directly relating to this.
Is this kind of plot possible using ggplot?
Thanks for any and all help!
They do use R but their ggplot2 theme is semi-proprietary and they don't say what they use. People have attempted to recreate the theme
https://github.com/jrnold/ggthemes
After the graphs are created it then goes through an illustrative step to bring graphs together and make them more of a story.
This seems like a straightforward problem, yet I can't find a solution. In Sage, I've got about 30 sorted points for a scatter_plot, and I want to add the order position as a label. I know this is easy if I were working with a graph object, since I could use the vertex_labels option in plot. Is there a simple fix to get this to work for a scatter_plot, or would I need to do something like make the points vertices and keep track of the exact location of each point
Currently, you may have to use matplotlib directly or mess around with that method inside of Sage to get this. See here or here for some related questions.
I've opened Trac 20583 for this.
I was trying to allow the user to give a curve as input for some analysis. Is there a package that can be used in this regard? Basically, a GUI like paint wherein the user can draw a simple curve and which would be stored in R as a set of data points or as an equation if its a simple curve.
Thanks
Gopher
Reading mouse input
Below is a list of sample approaches to first the problem, from the most complex to simplest (IMHO).
I would recommend that you have a look at the
qtpaint
package.
Less laborious solution may involve looking at the way interactive
plots in Shiny are handled. Using the click option would
enable you to get the mouse cursor position. Together with the Shiny
framework this would provide a convenient wrapper to get mouse input
from a user.
Finally, third approach could rely on making use of the locator function available in the graphics package. Depending on what you intend to do, this may be the simplest solution as you could then use read values to inform generation of your graphic.
Generating graphics
Assuming that you got your values via the locator functionality you could attempt to draw your line using segments. It would be a little fiddly as you would have to translate your coordinates to some placement of the dot in your desired chart but this wouldn't computationally too taxing, just a matter of bring mouse pointer values to some x/y values on the chart.
If you care to update your post with a sample code and reproducible attempts of your previous work, I bet the question will receive more replies. You may find this discussion on making a reproducible example in R helpful.
Sorry for the question, but I have a variable that I would like to plot like this:
I am a newby on R, so I am having some difficulties. I appreciate any kind of help.
Thanks!
Since you're looking to plot what appears to be a 3d surface, I'd suggest starting with the persp function, from the graphics package. This blog post (http://www.r-bloggers.com/3d-plots-in-r/) gives a good treatment of several options for 3D plotting:
the generic function persp() in the base graphics package draws perspective plots of a surface over the x–y plane. Typing demo(persp) at the console will give you an idea of what this function can do.
And running demo(persp) gives you a number of examples, including this one:
There are also some more suggestions for going further:
The plot3D package from Karline Soetaert builds on on persp()to provide functions for both 2D and 3D plotting. [...] Load the package and type the following commands at the console: example(persp3D), example(surf3D) and example(scatter3D) to see examples of 3D surface and scatter plots.
As a side note, #rawr's comment is spot on - I found all this in less than a minute, using two google searches - one of which was the title of your post. I'm putting this answer up anyway, since StackOverflow posts frequently become the top google result for many topics. But the best advice I can give you going forward is that R is one of the most aggressively well-documented languages out there, both in terms of formal and informal documentation, and you can find a lot just by googling what you want to do.
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.