Ali
Ali

Reputation: 9850

Plot in nowhere

I am using the function plotMDS() of package limma that makes a plot by the simple plot() format of R, and also returns the position of the points on the plot as output. I want to use the output of plotMDS() to produce my own beautiful plot.

Is there any way to run plotMDS() without having it's plot really generated? The reason I ask so is that I have already casted the output to a PDF file and I don't want the original plot of the plotMDS() to be there!

Upvotes: 2

Views: 366

Answers (2)

Dason
Dason

Reputation: 61983

Looking at your answer it seems like this might be a reasonable alternative:

mds <- plotMDS(data)
pdf("Some file")
...
plot(...) # Making the desired plot using mds
...
dev.off() # Closing PDF file

I don't know exactly what you're doing but if you're interested in reproducible documents then you could also use the knitr package to create your output. It would be very easy to suppress a single plot and then plot later using knitr.

Upvotes: 2

Ali
Ali

Reputation: 9850

Thanks @BenBolker, it can be done like this:

pdf("Some file")
...
dev.new() # Putting new plots to nowhere
mds <- plotMDS(data)
dev.off() # Restoring new plots to the PDF file
plot(...) # Making the desired plot using mds
...
dev.off() # Closing PDF file

Upvotes: 5

Related Questions