Corrplot visualization - r

I try to use R package - corrplot.
An example, i do this code:
M<-cor(mtcars)
corrplot(M, method="circle")
I get this image. It's ok, but if I want to look it inr my RStudio, i get this:
The image is shifted down, part of the characters are not visible. If there were more variables to correlate, it would be much worse. Maybe there are customizable parameters for image output and / or centering it?

Related

Par() function in R,plot not shown

Hey there stackoverflow geeks, I am working with a dataset in R language using R studio. I want to display my pareto charts side by side so better analysis can be done.
When I use par() function , i only get the first plot with an empty white space on right, can anyone please help me with what the issue is?
library(qcc)
stateRegion <- table(state.region)
stateDivision <- table(state.division)
par(mfrow=c(1,2))
pareto.chart(stateRegion) #only this one appears
pareto.chart(stateDivision) #this one is not plotting
EDIT
The code is working with all other plots except pareto chart/plot.
Please help.

Blurry edges when using "corrplot" package in R

I'm using corrplot in R to plot the correlation matrrix. For some reason, the edges of the circles in the plot seems missing some pixels. The plot overall looks very rough. Please see the graph I plotted:
enter image description here
But the example I followed shows the plot is supposed to be like this:
enter image description here
My initial guess was dpi and scaling issue because I use a 4K display. I tried changing the resolution and size of the plots but it doesn't work.
Thank you so much for your help.

How do I make the table fit in the image created by tableGrob?

I am using tableGrob in R to create a .png image of a formatted table, for inclusion in a MS Word report. For small tables this works, but for larger ones they do not fit in the image. I haven't been able to find any parameters that allow me to either force it to fit automatically, or to manually control the height and width of the image window.
I would be very grateful if somebody could show me how to do this.
I am using R version 3.3.1, via Rstudio version 1.0.136, on Linux Mint on a 64-bit PC. R packages used include gridExtra, gridGraphics, gtable and png.
The table (tabsave) is a simple data frame with 34 rows and six columns, the first being chr and all the others num.
Here is what the output looks like. You can see how the table extends beyond both the upper and lower borders of the image:
Here is the relevant code
gtab<-tableGrob(tabsave,rows=NULL,cols=nm,theme = ttheme_default(base_size=10)) # gtab is the graphical version of the table, for printing
png('test.png')
grid.draw(gtab)
dev.off()
Thank you for any help you can provide.
The solution is to give width and height parameters to the png function. They both default to 480, in the default unit of pixels (px).
So I just changed
png('test.png')
to
png('test.png',height=1200)
I played around with the width and height parameters until it gave the coverage I needed.
When the plotting is to the interactive plot device, rather than to a file (ie not using a function like png) it's just a matter of first resizing the plot window so it's big enough.

corrplot margins in RStudio are too small

When I produce a graphic in R-Studio, the margins are too small that it cuts off the graphic in the plot area. The output below follows this tutorial, which uses the corrplot library to run Pearson Chi-square residuals. No matter how I adjust my plot area or zoom or export, the bottom is still cut off. How do I adjust this?
I get the image displayed just fine. Maybe you can try playing around with the margins - mar parameter that is also internal to corrplot()
Here is what I get with some margins:
corrplot(chisq$residuals, is.cor=FALSE, mar=c(5,2,2,1))
You can also try transposing the matrix so it becomes extended horizontally, but not sure if that fits your needs:
corrplot(t(chisq$residuals), is.cor=FALSE, mar=c(5,2,2,1))

How to save a graphic in R instead of visualizing it?

I a bit of code that produces a matrix. I then generate a heatmap from this matrix using the function:
heatmap(d)
However, I would like to be able to save this img directly and bypass displaying the graphic, so that I can incorporate this function into a unix-based workflow.
Can someone please show me the snippet of code required to save this image without displaying it on screen? Thanks!
Use jpeg(), png() or tiff() to create the file.
jpeg(file="filename.jpg")
heatmap(d)
dev.off()

Resources