I can't seem to find much information on this. I would like to rotate the main plot in and image while leaving the legend and title unaltered.
Here's an example. You'll need fields
package which gives you the image.plot
function.
x=1:10
y=1:10
z=matrix(-50:49,10,10)
image.plot(x,y,z, main="Some Fancy Title",yaxt="n",xaxt="n", ylab="", xlab="")
So again I just want to rotate the main image and leave the title and legend in place. Btw I'm rotating 36 degrees so I can't just rotate the matrix I'm feeding image.plot
. The grid
package seems to lead me in the right direction but it is frustrating how I cannot plot directly into their so called viewports
with plot or anything else from base
. I must say not a fan of the grid
package so far.
I found this post which provides some helpful information in answer 5. I know from this that I should be able to use grid.cap()
to capture a raster of my device and use grid.raster(cap, vp=viewport(angle=36))
to import the plot into the correct viewport. I'm having problems getting this method to working for me and it seems pretty inefficient to boot. I will be plotting literally thousands of images to create gifs of various temporally and spatially varying data I have modeled.
What I'm looking for is either a way to get grid.cap()
to work with the above example and rotate only the main part of the image 36 degrees or an alternative doing the same thing that will work well with my volume of plots. Much thanks to anyone that gives this some thought.