These days I am extensively using R to scatter plots.
Most of the plotting is concerned with image processing,
Recently I was thinking of plotting the scatter plots over an image.
For example, I want something like this,
The background needs to be filled with my image. With a particular scale.
And I should be able to draw points (co-ordinates) on top of this image ...
Is this possible in R?
If not, do you guys know of any other tool that makes this easy ...
I'm not 100% sure what you have in mind, but I think first you want to load and plot an image in R. You can do that with the ReadImages package:
picture <- read.jpeg("avatar.jpg")
plot(picture)
Then you can do a scatter plot on top of it:
points(runif(50,0, 128), runif(50,0,128))
A step-by-step tutorial to this kind of plotting is in the R-wiki
Related
My goal is to make an interactive plot of rain radar time serie, I want to is display the raster layer I want through a scroll bar in the plot area, or with HTML output like dygraph can do.
For now, I use the raster, levelplot and animate packages to make a gif of the event (with sp to add shapefile), but the result is not very good for my use of it, and not pretty.
Is that possible and how?
I tried to use the htmlwidget and leaflet without success. They do not allow the multiband raster except for RGB purpose. so when I tried, it gaves me the sum of all the layers in one.
I don't know what script I could give to help you. Ask me if you need something.
I am trying to create contour plots of film thicknesses on a wafer using plotly, but would like the outputted plot to be a circle since it is a wafer instead of the default square. Do I have to somehow overlay a circle on to the plot and then exclude anything outside of it after the plot is generated? I prefer using plotly if possible since it looks nice. I've tried using ggplot as well but for some reason my data doesn't work with it since the x and y coordinates are apparently irregularly spaced. I've searched around but have not seen any results at least using R.
Thanks!
What I would like to do is make a series of plots that combine an image with a scale that is related to the height of the image, but is multiplied by a factor.
So far I've been able to make a plot using the following code:
library(imager)
im <- load.image("ZAB17_4.png")
plot(im)
Image is attached here
But what I would like to do is to have the y-axis be scaled by a value:
pixel_size <- 0.0596
I would also get rid of the x-axis. (xaxt="n" doesn't seem to do the trick). Ideally, I would like the Y-axis to be directly adjacent to the image. I've been trying to poke around with scales in the plot function, but haven't found what I need to do this, but I'm sure there is a simple solution.
*Edited to add image. I should note that the goal is really just to add a scale to the image. The pixel size represents the size of each pixel in reality in mm. I basically want to add a ruler along the side of the image. Maybe r is not the best tool for this, but I plan to also plot data taken from the imaged object and plot it alongside.
Any help is appreciated.
I'd like to achieve what this person has achieved without using ggplot. Any ideas?
How do I create a continuous density heatmap of 2D scatter data in R?
You can see what I get when using the solution detailed in that question.
ggplot(df,aes(x=x,y=y))+
stat_density2d(aes(alpha=..level..), geom="polygon") +
scale_alpha_continuous(limits=c(0,1),breaks=seq(0,1,by=0.1))+
geom_point(colour="red",alpha=0.2)+
theme_bw()
The heatmap is so sparse. I want it to cover much more than what it is covering now. It's terribly hard to see anything about the density. Any ideas of different ways to make density heatmaps from 2D data besides this ggplot solution?
One idea I had was instead of using linear color labeling (see the black to white spectrum on the left, which is linear), using logarithmic scale for the density labeling. Any ideas how I could do this?
"The heatmap is so sparse. I want it to cover much more than what it is covering now. It's terribly hard to see anything about the density."
Please be specific: what do you want to see in areas with most or all NAs?
if you use geom_point with alpha-blending and position_jitter, the current plot is as good as it gets
if some solid color, then use geom_hex(), see http://mfcovington.github.io/r_club/solutions/2013/02/28/peer-produced-plots-solutions/ for code. Then play with the continuous color_scale... you probably want a nonlinear transform. Post us your revised attempt, if you want a critique.
I actually ended up using smoothScatter, which works well and uses classic R plotting.
I have a set of data that I'm trying to create a surface plot of. I have an x,y point and a to colour by.
I can create a xy plot with the points coloured but I can't find a way to create a surface plot with my data. The data isn't on a normal grid and I would prefer to not normalize it if possible (or I could just use a very fine grid).
The data won't be outside the a radius=1 circle so this part would need to be blank.
The code and the plot is shown below.
I've tried using contour, filled.contour as well as surface3d (not what I wanted). I'm not real familiar with many packages in R so I'm not even sure where to begin looking for this info.
Any help in creating this plot would be appreciated.
thanks,
Gordon
dip<-data.frame(dip=seq(0,90,10))
ddr<-data.frame(ddr=seq(0,350,10))
a<-merge(dip,ddr)
a$colour<-hsv(h=runif(nrow(a)))
degrees.to.radians<-function(degrees){
radians=degrees*pi/180
radians
}
a$equal_angle_x<-sin(degrees.to.radians(a$ddr))*tan(degrees.to.radians((90-a$dip)/2))
a$equal_angle_y<-cos(degrees.to.radians(a$ddr))*tan(degrees.to.radians((90-a$dip)/2))
plot(a$equal_angle_x,a$equal_angle_y,col=a$colour,lwd=10)
With regards to the plot I was trying to create is below. I believe the link in the first comment should get me where I'm trying to go.