How plot a discontinuous distribution function in R - r

I hope i do all well, because I am new to this forum.
I try to plot a distribution function of discontinuous values like a cube
Can I do in r anything like the picture on this website?
http://www.dietrichgrude.de/stochastik/zufvar_vertfkt.gif
Thanks and greetings

You can use plot.stepfun function. See examples of it with
example(plot.stepfun)

Related

Phase plot in R

I want to make a phase plot like this https://en.wikipedia.org/wiki/Phase_portrait from an non-linear time series in R, Any ideas?
Thank you
you haven't given many details, but I suggest you look at the package phaseR.
I use it to draw isoclines and a flowfield of predator-prey models.
My graphs look like this (right one):

Get PCA datapoints in R

I am using the following example to test my data in pca.
I was hoping to extract the data points used to plot PCA scatter chart with ggbiplot function. I couldnt find anything in ggbiplot documentation, but maybe someone is aware of an alternative ?
Thank you
The ir.pca object has several properties, and one of them is "x", which had all the points I was looking for.
This was what led me to an answer.

changing default colours when using the plot function of the R package mixtools

I have a plotting problem with curves when using mixtools
Using the following R code
require(mixtools)
x <- c(rnorm(10000,8,2),rnorm(10000,18,5))
xMix <- normalmixEM(x, lambda=NULL, mu=NULL, sigma=NULL)
plot(xMix, which = 2, nclass=25)
I get a nice histogram, with the 2 normal curves estimated from the model superimposed.
The problem is with the default colours (i.e. red and green), which I need to change for a publication to be black and grey.
One way I thought to doing this was first to produce the histogram
hist(xMix$x, freq=FALSE, nclass=25)
and then add the lines using the "curve" function.
....... but I lost my way, and couldn't solve it
I would be grateful for any pointers or the actual solution
thanks
PS. Note that there is an alternative work-around to this problem using ggplot:
Any suggestions for how I can plot mixEM type data using ggplot2
but for various reasons I need to keep using the base graphics
You can also edit the colours directly using the col2 argument in the mixtools plotting function
For example
plot(xMix, which = 2, nclass=25, col2=c("dimgrey","black"))
giving the problem a bit more thought, I managed to rephrase the problem and ask the question in a much more direct way
Using user-defined functions within "curve" function in R graphics
this delivered two nice solutions of how to use the "curve" function to draw normal distributions produced by the mixture modelling.
the overall answer therefore is to use the "hist" function to draw a histogram of the raw data, then the "curve" function (incorporating the sdnorm function) to draw each normal distribution. This gives total control of the colours (and potentially any other graphic parameter).
And not to forget - this is where I got the code for the sdnorm function - and other useful insights
Any suggestions for how I can plot mixEM type data using ggplot2
Thanks as always to StackOverflow and the contributors who provide such helpful advice.

Plot density distribution

I have generated a bunch of data, and want to plot how they are distributed using matplotlib. How should I proceed?
Thank you for answers
hist is a nice way to see a distribution. See here for details.

R equivalent of Matlab trisurf()

I have three vectors x, y, U that I would like to plot as a surface. I can do this in Matlab using functions delaunay() and trisurf(). However, I would like to do the same in R but can't find something similar.
Any help appreciated.
See the geometry package for delaunayn and surf.tri, and these can be plotted with rgl.triangles from rgl.
http://www.inside-r.org/packages/cran/geometry/docs/surf.tri
I used this recently here https://gis.stackexchange.com/questions/90635/what-programs-would-allow-for-the-mapping-of-a-geoid-in-3d/90763#90763
You can do trisurf with Plotly's open-source R client. R code here:
http://moderndata.plot.ly/trisurf-plots-in-r-using-plotly/

Resources