Change axis length in polar.plot? - r

I want to draw a polar graph in R.
I found plotrix, which has polar.plot, but I'm open to any other solutions.
It plots a polygon just fine, even though I have a few thousand points, so great!
My question: how can I change the start value of the radial axis? ie, how to do ylim in polar.plot?

Try using ggplot2 - it has a coord_polar() command to make polar plots
Here's the official Documentation:
http://docs.ggplot2.org/current/coord_polar.html
And a simple tutorial to work off of:
http://learnr.wordpress.com/2010/08/16/consultants-chart-in-ggplot2/

I found a solution for polar.plot: option radial.lim.

Related

Combined ggplot and plotrix

I need to add a Y axis break to a plot I made in ggplot. Is it possible to use the gap.barplot function in plotrix in a graph in ggplot? When I try, it cancels everything I did in ggplot and plots just the gap.barplot bit.
Thank you
Barbara
Unfortunately NO.
They work on two different "worlds".
I've been trying a lot but it seems (just like #Mark Peterson wrote) that doing this in ggplot is nearly impossible on purpose
You should look into these questions and answers which are very similiar:
Using ggplot2, can I insert a break in the axis?
Broken barplot using R/ggplot2

Ternary Plot detail/clipping in R

I have used triax.plot to create a ternary plot.
require(plotrix)
data <- read.csv("~/R/datasets/data.csv")
triax.plot(data[1:18721,],main="ternary plot", tick.labels=list(b=seq(10,90,by=10),l=seq(10,90,by=10),r=seq(10,90,by=10)), pch=4)
However most of the data forms a cluster that I want to display in more detail. I would like to edit the axis range (not the labels, not the ticks) to display only the relevant area of the original plot
highlighted in this image. The resulting clipping would also be a isosceles triangle.
Apparently triax.plot has no option for this. Or am I missing something? Any suggestions for alternative approaches are appreciated. Thanks in advance!

How to plot tif over gmap tile in R

I want to plot a raster (.tif) over my gmap tile in R. It can be done with simple plot() function or with ggplot2 or with dismo gmap function. I found several examples, but none of them is really working for me.
Here is the simpliest way I was able to understand:
r<- raster(whatever.tif)
g<-gmap()
plot(g)
plot(r, add= TRUE)
This displays the correct gmap tile, it plots the desired raster, BUT it overlays also a huge legend over the whole visualization, making it not useful anymore.
From the question its obvious I am beginner. Thanks for any help!
Quick fix!
plot(raster(x), add=TRUE, legend=FALSE)
This will suppress your legend. If you desire to add a legend later check out ?legend.

Trying to make twoord.plot interactive

I have a plot that I created using thet twoord function. I am trying to make it an interactive graph so that I can hover around a point with my mouse and see what the x,y coordinates are for that plot.
I can't figure out how to do this with the twoord.plot function. Any idea how to do this?
My apologies, I was misreading the R command for identify. FYI, just place this code: identify(x, y, labels=row.names(mydata)) after the plot command and you are able to select points accordingly.

R - Scatter plots, how to plot points in differnt lines to overlapping?

I want to plot several lists of points, each list has distance (decimal) and error_no (1-8). So far I am using the following:
plot(b1$dist1, b1$e1, col="blue",type="p", pch=20, cex=.5)
points(b1$dist2, b1$e2, col="blue", pch=22)
to add them both to the same plot. (I will add legends, etc later on).
The problem I have is that points overlap, and even when changing the character using for plotting, it covers up previous points. Since I am planning on plotting a lot more than just 2 this will be a big problem.
I found some ways in:
http://www.rensenieuwenhuis.nl/r-sessions-13-overlapping-data-points/
But I would rather do something that would space the points along the y axis, one way would be to add .1, then .2, and so on, but I was wondering if there was any package to do that for me.
Cheers
M
ps: if I missed something, please let me know.
As noted in the very first point in the link you posted, jitter will slightly move all your points. If you just want to move the points on the y-axis:
plot(b1$dist1, b1$e1, col="blue",type="p", pch=20, cex=.5)
points(b1$dist2, jitter(b1$e2), col="blue", pch=22)
Depends a lot on what information you wish to impart to the reader of your chart. A common solution is to use the transparency quality of R's color specification. Instead of calling a color "blue" for example, set the color to #0000FF44 (Apologies if I just set it to red or green) The final two bytes define the transparency, from 00 to FF, so overlapping data points will appear darker than standalone points.
Look at the spread.labs function in the TeachingDemos package, particularly the example. It may be that you can use that function to create your plot (the examples deal with labels, but could just as easily be applied to the points themselves). The key is that you will need to find the new locations based on the combined data, then plot. If the function as is does not do what you want, you could still look at the code and use the ideas to spread out your points.
Another approach would be to restructure your data and use the ggplot2 package with "dodging". Other approaches rather than using points several times would be the matplot function, using the col argument to plot with a vector, or lattice or ggplot2 plots. You will probably need to restructure the data for any of these.

Resources