Code covered by the BSD License  

Highlights from
logzplot

5.0

5.0 | 3 ratings Rate this file 24 Downloads (last 30 days) File Size: 9.37 KB File ID: #29317
image thumbnail

logzplot

by

 

08 Nov 2010 (Updated )

Easily create surface plots with logarithmic z-axis and color scale.

| Watch this File

File Information
Description

LOGZPLOT is an easy way to create surface plots with both a log-scaled z-axis and log-scaled coloring. LOGZPLOT creates a plot using SURF, MESH, IMAGE, PCOLOR, TRISURF or TRIMESH, then applies the logarithmic transformation. If called without data inputs, LOGZPLOT will apply the logarithmic scaling to an existing surface plot.

Although creating a plot like LOGZPLOT's output is easy to do from the command line, getting a colorbar to display the correct data range requires some additional scaling of the color data. LOGZPLOT automatically scales the color data so that a colorbar will have a scale corresponding to the input data, even after changing the axes' 'CLim' property. To do this, LOGZPLOT attaches a listener function to the axes that corrects the color data scaling whenever the 'CLim' property changes. This allows the user to specify 'CLim' values in the normal units of the original data.

See the help text for additional information and examples.

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
18 Jun 2013 Rhys  
31 May 2012 John Barber

Felipe,

Thanks for the suggestions. I've included them in the latest version.

-John

16 May 2012 Felipe

Thanks a lot for your submission. I like specially the colorbar update callbacks. I was mostly interested in the log-scaled colorbar. I wanted to use it for images. I could get the picture that I wanted plotting the data as a surface then setting view(2) and 'EdgeColor','none', but for large images it's slower. So I've added support for images, e.g., logzplot(X,Y,Z,@image,'colorbar'), or h=image(Z); logzplot(h,'colorbar'); I also needed the colorbar handle (to adorn it with titles, etc.) so now it's a return value. Here are the diffs in case you want to incorporate:

1c1
< function h = logzplot(varargin)
---
> function [h,h2] = logzplot(varargin)
283c283
< plotFunList = {'surf','pcolor','mesh','trisurf','trimesh'};
---
> plotFunList = {'surf','pcolor','mesh','trisurf','trimesh','image'};
349c349
< case {'surf','mesh','pcolor'}
---
> case {'surf','mesh','pcolor','image'}
453a454,456
> case 'image'
> CDataName = 'CData';
> pcolorFlag = 1; % avoid setting ZScale.
485a489,498
> case 'image'
> CDataName = 'CData';
> pcolorFlag = 1; % avoid setting ZScale.
> if isvector(x), x2 = x; else x2 = x(1,:); end
> if isvector(y), y2 = y; else y2 = y(:,1); end
> hAx2 = gca();
> axes(hAx) %#ok<MAXES>
> hSurf = plotFun(x2,y2,CData);
> axes(hAx2) %#ok<MAXES>
> set(hAx, 'YDir','normal')
537a551
> hCbar = [];
539c553
< LogZPlotColorbar(hFig,hAx)
---
> hCbar = LogZPlotColorbar(hFig,hAx);
567c581
< if nargout == 1
---
> if nargout > 0
569a584,586
> if nargout > 1
> h2 = hCbar;
> end
683c700
< case {'surface','patch'}
---
> case {'surface','patch','image'}
702c719
< hSurf = findobj(hAx,'Type','surface','-or','Type','patch');
---
> hSurf = findobj(hAx,'Type','surface','-or','Type','patch','-or','Type','image');
725c742
< function LogZPlotColorbar(hFig,hAx,hCbar)
---
> function hCbar = LogZPlotColorbar(hFig,hAx,hCbar)

16 May 2012 Felipe  
28 Dec 2011 gmart  
Updates
30 Nov 2010

- Added support for trisurf and trimesh plots
- Improved speed and memory performance
- Improved colorbar support

31 May 2012

- Added support for plots using IMAGE
- Added colorbar handle output
- Fixed CLim equality test bug

Contact us