I need your help...to solve my problem...
I want to use the plot()
function from R
in C#
. However, I don't know how to put the plot that I get from R, into picture box or panel in C#.
Here the code that I've used to get plot from R:
engine.Evaluate("r.plot <- plot(r$condition, r$access,
main='condition category vs access category',
xlab='condition', ylab='access',
pch=1, col='blue')" );
How could I put the plot into picture box or panel in C# ???
R language comes with a graphics package with a generic function called plot (), which is versatile and can be used to create different types of (X, Y) plots with points and lines. The plot in R is a built-in generic method for plotting objects. The plot () isn’t a single defined function but a placeholder for a family of related functions.
Plot function in R. The R plot function allows you to create a plot passing two vectors (of the same length), a dataframe, matrix or even other objects, depending on its class or the input type. We are going to simulate two random normal variables called x and y and use them in almost all the plot examples.
To create a line plot, pass the parameter type = “l” inside the plot function. And we get the line chart of the y = x^3 function. If we don’t pass the type = “l” in the argument, it will return the points plot. By default, the plot () function returns point plot. To calculate the cosine value in R, use the cos () function.
R axis function. The argument axes of the plot function can be set to FALSE in order to avoid displaying the axes, so in case you want, you can add only one of them with the axis function and customize it. Passing a 1 as argument will plot the X-axis, passing 2 will plot the Y-axis, 3 is for the top axis and 4 for the right axis.
The best working option is to save a file from R and open with a picture box. A couple of contributors to R.NET wrote code currently in an alpha NuGet package R.NET.Graphics. This was a prototype for a seamless graphic device for R. A fully fledged device would be a lot of work, and this graphics module is not actively developed currently (anyone game for it out there?).
Have a look at RDotNet.Graphics.Tests there is code showing side by side the visual output via R.NET.Graphics and from a loaded file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With