Code covered by the BSD License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

Highlights from sanePColor

4.57143
4.6 | 7 ratings Rate this file 18 Downloads (last 30 days) File Size: 2.83 KB File ID: #35601 Version: 1.1

sanePColor

Jeremy Manning (view profile)

12 Mar 2012 (Updated )

Wrapper for pcolor that behaves similarly to imagesc. Squash OS X Preview's "blurry image" bug!

File Information
Description

sanePColor simple wrapper for pcolor

Unlike the built-in pcolor command, this function does not "cut off" the
last row and column of the input matrix. In this way, sanePColor is
intended to be as easy to use as imagesc, but allows the user to specify
the x and y coordinates of each cell if desired. This function is also
useful as an alternative means of generating images to print to PDF that
are compatible with OS X's "Preview" PDF viewer (imagesc images appear
"blurred" when printing to a PDF as a vector graphic and viewed using
Preview).

NOTE: The imagesc function assumes that each entry in a matrix gets the
corresponding coordinate in 2-d space. For example, entry (2,3) in the
matrix is assigned to the coordinate with x = 3, y = 2 when using
imagesc. The pcolor function assumes that entries correspond to *edges*.
So entry (2,3) in a matrix corresponds to the value between 2 and 3
(along the x-axis) and between 1 and 2 (along the y-axis). This is why
one row and one column are cut off when using pcolor. sanePColor
behaves like imagesc (i.e. does not cut off data), but uses the "edge
assignment" data representation required by pcolor. sanePColor uses
linear or logarithmic interpolation to infer the edges automatically.

Usage: p = sanePColor([x,y],z,[logx],[logy]);

INPUTS:

x: an array of sorted x values. can also specify a min and max x value.
these values correspond to columns of z. [IF THIS ARGUMENT IS USED,
MUST ALSO SPECIFY Y VALUES.]

y: an array of sorted y values. can also specify a min and max y value.
these values correspond to rows of z. [IF THIS ARGUMENT IS USED,
MUST ALSO SPECIFY X VALUES.]

z: a 2d matrix of values. this matrix determines the color at each
point.

logx: if this optional argument is set to true, the x-axis will plotted
in log scale (similar to semilogx).

logy: if this optional argument is set to true, the y-axis will plotted
in log scale (similar to semilogy).

OUTPUTS:

p: a handle to the resulting pcolor image.

EXAMPLE:

m = membrane;
p = sanePColor(m);

AUTHOR: JEREMY R. MANNING
CONTACT: manning3@princeton.edu

Acknowledgements
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Comments and Ratings (9)
26 Feb 2016 Frederik Tilmann

Frederik Tilmann (view profile)

11 Aug 2015 Nitin

Nitin (view profile)

05 May 2014 Seb Biass

Seb Biass (view profile)

Hey, really cool code. I am trying to input matrices of X and Y to mimic the example of pseudo-polar coordinates shown as an example of the help of pcolor. Is that possible somehow with your code?
Thanks!
S

04 Jan 2014 Jonathan C. Lansey

Jonathan C. Lansey (view profile)

Really nicely done function with a hilarious name to avenge for the frustration of using pcolor.

10 Jun 2013 David Wang

David Wang (view profile)

x and y have to be row vectors. To be more flexible, replace in the linexpand function

x = 1:length(y);
p = polyfit(1:length(y),y,1);

with

x = reshape(1:length(y),[size(y)]);
p = polyfit(x,y,1);

21 Sep 2012 Jeremy Manning

Jeremy Manning (view profile)

Hi Jette, thanks for your feedback. I have corrected the issue you described (the new version should appear shortly).

Comment only
19 Sep 2012 Jette

Jette (view profile)

The handling of the axes is not correct as you can see using the Data Cursor. This also can yield strange ticks.

However, it solves the problem that at least all data of a matrix is shown.

Comment only
19 Sep 2012 Jette

Jette (view profile)

29 Jun 2012 avlas

avlas (view profile)

very nice, I was dealing with this issue in pcolor

thanks a lot