Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a plot from R in C#

Tags:

c#

plot

r

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# ???

like image 368
Wiwik Andriyani Avatar asked May 08 '15 15:05

Wiwik Andriyani


People also ask

How to create a plot in R?

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.

What is the use of X and Y in R plot?

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.

How to calculate cosine value in R plot?

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.

How to use the axis function in an R plot?

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.


1 Answers

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.

like image 163
j-m Avatar answered Sep 30 '22 04:09

j-m