I'm trying to make a visualization that looks like this http://www.gradient-da.com/img/temperature%20surface%20plot%20470x406.JPG http://www.gradient-da.com/img/temperature%20surface%20plot%20470x406.JPG.
The idea is to have a 3D surface plot overlapping a 2d representation of a surface.
I can build arbitrary surfaces/polygon shapes (as in http://addictedtor.free.fr/graphiques/graphcode.php?graph=135 ) and I can make the respective 2D plot. What I don't seem to be able to figure out is the way to put them together in a nice way (like the one shown in the jpg above).
I've tried googling for the answer, but I wasn't able to find anything similar done in R.
Any help would be greatly appreciated!
EDIT: The 2D portion is not a projection of the 2D one. I chose this specific picture to illustrate this. For example
Here the 2D portion is the image of the circuit and on the 3D portion is the temperature).
In 2D you can have the map of a city and in 3D the traffic
etc...
Best,
Bruno
I will give a theoretical Idea,
In the same 3D plot, select a plane perpendicular to the 3D surface (just below the 3D-surface) and project all the values to it. Instead of 2D & 3D plot, you will use only a 3D plot, which also plots your surface.
HTH
It looks like the 2D plot is a layout of a microelectronic circuit, albeit with some detail skipped, and the 3D plot is perhaps a thermal plot of the same circuit.
I don't know enough about R's capabilities, but I imagine it would be easier to generate the two plots separately with R from the same dataset which represents the layout information (but with and without the thermal data) and then combine them with a graphics manipulation program.
No help in R, but you can do something similar in ROOT as seen in this image:
taken from the THistPainter class documentation.
The code is open source and could be examined if wanted for reimplementation.
Maybe you should try to make an opengl texture out of your 2d picture and map it on a 3d polygon to be included in your scenegraph?
Don't really understand if you wish to do it with R specifically, so maybe diving in opengl is a too low level for you. In case you'd be ready for that, you may reuse a simple java library that simplify plotting 3d surface: http://code.google.com/p/jzy3d
Hope that helps,
Martin
What you're looking for is called a texture map -- and if it's not provided in the R graphics package, you may be able to do it "by hand". The suggestion below may not be fast or convenient (or even helpful, as I'm not really familiar with R), but it may actually work...
Since you know you can draw a 3D surface plot with specified colors, you can try drawing a flat 3D surface using the colors of your image.
If R also lacks methods for extracting its data from image formats, there is an image format called PPM (standing for Portable PixMap), one variant of which is basically space-separated decimal numbers. After converting your image to this format (using Photoshop, say, or some dedicated image conversion program), it should be relatively easy to input into R.
Related
I want to plot the recorded path of an object such as a plane or drone in 3d space using R. The plotted path should be represented by a flat “ribbon” whose orientation perpendicular to the direction of travel changes to reflect the roll of the object. In other words, I want to be able to visualize the path and orientation of the object in one "ribbon" as it banks in turns.
As far as as I can tell, a traditional ribbon plot in R won't allow you to change the orientation in a third dimension.
Matlab and Python have functionality for creating quiver plots where arrows may be placed to indicate the xyz orientation of the object at a given point in time along the path. I cannot find any R packages with similar functionality.
I have played with Plot3D, Plotrgl, Plot3Drgl and cannot find a package that has this capability.
Q1: Are there any packages in R that would support this type of plot?
Q2: If there isn't, how can I go about creating this type of plot R?
Below are examples in Python and Matlab for the 3D quiver type plots, as well as an image demonstrating the ribbon concept I am imagining.
https://medium.com/analytics-vidhya/exploring-data-acquisition-and-trajectory-tracking-with-android-devices-and-python-9fdef38f25ee
Example of 3D quiver plot in python
https://github.com/xioTechnologies/Gait-Tracking-With-x-IMU
Example of 3D quiver plot in matlab
This is an example of what the "ribbon" would look like
Thanks for any help!
I am looking for a way to draw a 3d line plot. Preferably I would like to use the datavisualization framework, but it does not seem to provide this out of the box.
I experimented a little bit and ended up using 3D surface plots (Surface3D) displaying the lines as surfaces (i.e. ribbons) like this:
While this works and looks okay in above picture the thickness of the line depends on the perspective. Rotating the plot always allows to find the angle where the line disappears since it has not thickness:
Is there a type of plot that would be better suited for this? I tested the bars which don't perform well for lots of samples and don't look nice in my application. I also tested scatterplots which are not suitable either.
If there isn't: Where would I start to implement this myself on top of the existing classes in the datavisualization framework? I am thinking about adding another surface "ribbon" in z direction, however that seems a little hackish.
I used the technique described as hackish above. While I am not too happy about the approach the overall look is quite okay:
So basically each data line consists of three QSurfaceDataRows that together form two 90° ribbons as can be seen here:
Here is what I need: I have an image and want to plot on specific rectangle-shaped parts of it (e.g., imagine having a picture of a chessboard and wanting to fill every square with a different color). I would like to be able to easily specify the coordinates for these parts and take these coordinates into R for plotting.
I don't have any experience with making such plots. I've thought of simply inserting an image into a plot with rasterImage (), then plotting with polygon (), but the task of setting up the coordinates for the polygon function seemed too time consuming - hence the question above.
If you have any better ideas than using a set of coordinates for the polygon function, please share. Any leads or packages suggestions would also be helpful.
thank you. Marko.
I have a scanned map from which i would like to extract the data into form of Long Lat and the corresponding value. Can anyone please tell me about how i can extract the data from the map. Is there any packages in R that would enable me to extract data from the scanned map. Unfortunately, i cannot find the person who made this map.
Thanks you very much for your time and help.
Take a look at OCR. I doubt you'll find anything for R, since R is primarily a statistical programming language.
You're better off with something like opencv
Once you find the appropriate OCR package, you will need to identify the x and y positions of your characters which you can then use to classify them as being on the x or y axis of your map.
This is not trivial, but good luck
Try this:
Read in the image file using the raster package
Use the locator() function to click on all the lat-long intersection points.
Use the locator data plus the lat-long data to create a table of lat-long to raster x-y coordinates
Fit a radial (x,y)->(r,theta) transformation to the data. You'll be assuming the projected latitude lines are circular which they seem to be very close to but not exact from some overlaying I tried earlier.
To sample from your image at a lat-long point, invert the transformation.
The next hard problem is trying to get from an image sample to the value of the thing being mapped. Maybe take a 5x5 grid of pixels and average, leaving out any gray pixels. Its even harder than that because some of the colours look like they are made from combining pixels of two different colours to make a new shade. Is this the best image you have?
I'm wondering what top-secret information has been blanked out from the top left corner. If it did say what the projection was that would help enormously.
Note you may be able to do a lot of the process online with mapwarper:
http://mapwarper.net
but I'm not sure if it can handle your map's projection.
I recently found this web page Crime in Downtown Houston that I'm interested in reproducing. This is my first learning experience with mapping in R and thus lack the vocabulary and understanding necessary to make appropriate decisions.
At the end of the page David Kahle states:
One last point might be helpful. In making these kinds of plots, one
might tempted to use the map raster file itself as a background. This
method can be used to make map plots much more quickly than the
methods described above. However, the method has one very significant
disadvantage which, if not handled properly, can destroy the entire
purpose of using the map.
In very plain English what is the difference between the raster file
approach and his approach?
Does the RgoogleMaps package have the ability to produce these types
of high quality maps as seen on the page I referenced above that
calls a google map into R?
I ask not because I lack information but the opposite. There's too much and I want to make a good decision(s) about the approach to pursue so I'm not wasting my time on outdated or inefficient techniques.
Feel free to pass along any readings you think would benefit me.
Thank you in advance for your direction.
Basically, you had two options at the time this plot was made:
draw the map as a layer using geom_tile, where each pixel of the image is mapped onto the x,y axes (slow but accurate)
add a background image to the plot, as a purely "cosmetic" annotation. This method is faster, because you can use grid.raster which draws images more efficiently, but the image is not constrained by the axes of the plotting region. In other words, you have to manually adjust the x and y axes limits to make sure that the image corresponds to the actual positions on the plot.
Now, I would suggest you look at the new annotation_raster in ggplot2 v. 0.9.0. It should have the advantage of speed and leaner output files, and still conform to the data space of the plot. I believe that this function, as well as geom_raster and annotation_map did not exist when David made those plots.