I am new to R, and have previously used MATLAB. I am converting a MATLAB script to operate under R. So far so good except now to plot the output graph.
MATLAB
Here is the matlab code for plotting the graph, using imagesc
:
imagesc(velocity,time,myplot,[-35, 0]);
Where:
velocity
: 1 x 50 matrix
time
: 1 x 10 matrix
myplot
: 10 x 50 matrix
Explanation of Imagesc
More details can be found here
imagesc(x,y,C) displays C as an image and specifies the bounds of the x- and y-axis with vectors x and y. If x(1) > x(2) or y(1) > y(2), the image is flipped left-right or up-down, respectively. If x and y are scalars, the image is translated to the specified location (x,y) such that the upper left corner of the image starts at (x,y).
R
R's version of imagesc
which can be found here
The Question:
How can I reproduce the data value to colormap value in the Matlab clims
section, found here: http://i.imgur.com/eVy6V8N.png, which is the [-35, 0]
part of the Matlab example.
It maps data values outside of a particular range to the same color limit, effectively acting as a filter for noise on the image.
Here is the result of Matlab and R imagesc
function without the [-35, 0]
clims section: http://i.imgur.com/DzDjrzu.png
As you can see they are identical.
Here is the desired result, with Matlab [-35, 0]
section included: http://i.imgur.com/Qbx6jNI.png
Matlab of left and R on the right. The left Matlab image is what I want to produce, and it's all due to that one process clims
[-35, 0]
on the Matlab version of the script.