Thread Subject: How to plot with "imagesc" with logarithmic axis

 Subject: How to plot with "imagesc" with logarithmic axis From: Rebecca Date: 17 Jun, 2012 23:15:08 Message: 1 of 5 I need to plot an image, "apple" for example, that both x and y are in log axis. x = 10.^linspace(log10(0.1),log10(3),10); y = 10.^linspace(log10(1),log10(5),8); apple = (y'*x/10); imagesc(x,y,apple) set(gca,'YScale','log','YMinorTick','on','Ydir','normal') axis tight set(gca,'XTick',([0.1,0.3, 1,3])) set(gca,'YTick',([1 1.5 1.8 2.1 5]))    % lines below won't work set(gca,'XScale','log') set(gca,'XMinorTick','on') set(gca,'YScale','log') set(gca,'YMinorTick','on') Thanks for your help, Rebecca
 Subject: How to plot with "imagesc" with logarithmic axis From: Bruno Luong Date: 18 Jun, 2012 06:57:07 Message: 2 of 5 "Rebecca " wrote in message ... > I need to plot an image, "apple" for example, that both x and y are in log axis. > > x = 10.^linspace(log10(0.1),log10(3),10); > y = 10.^linspace(log10(1),log10(5),8); > apple = (y'*x/10); > imagesc(x,y,apple) > set(gca,'YScale','log','YMinorTick','on','Ydir','normal') > axis tight > set(gca,'XTick',([0.1,0.3, 1,3])) > set(gca,'YTick',([1 1.5 1.8 2.1 5])) > > % lines below won't work > set(gca,'XScale','log') > set(gca,'XMinorTick','on') > set(gca,'YScale','log') > set(gca,'YMinorTick','on') IMAGE and IMAGESC can't plot a irregular spaced pixel. You can merely change the ticklabel. Use patch or surf to plot irregular spaced data z=peaks(40); surf(1:40,1:40,zeros(size(z)),'CData',z, 'Linestyle','none') view(0,90) set(gca,'yscale','log') % Bruno
 Subject: How to plot with "imagesc" with logarithmic axis From: craq Date: 18 Jun, 2012 07:39:07 Message: 3 of 5 or you could use imagescnan (from the file exchange). Then you can either fudge your x and y axes: x_plot=log10(x); y_plot=log10(y); imagescnan(x_plot,y_plot,apple) or use the set(gca...) commands you listed before. also, instead of 10.^linspace, you may want to have a look at the function logspace
 Subject: How to plot with "imagesc" with logarithmic axis From: Rebecca Date: 18 Jun, 2012 19:23:09 Message: 4 of 5 Hi Bruno, Thanks for the reply. Imagesc can show both axes in logarithmic with "set(gca,'xoryscale','log')", but when I do this, the image goes blank. Since the original data points are evenly located at log axis, I need them be displayed in the same way. I didn't even know surf can be used for this task. Let me try! Rebecca "Bruno Luong" wrote in message ... > > > IMAGE and IMAGESC can't plot a irregular spaced pixel. > > You can merely change the ticklabel. > > Use patch or surf to plot irregular spaced data > > z=peaks(40); > > surf(1:40,1:40,zeros(size(z)),'CData',z, 'Linestyle','none') > view(0,90) > set(gca,'yscale','log') > > % Bruno
 Subject: How to plot with "imagesc" with logarithmic axis From: Rebecca Date: 18 Jun, 2012 19:25:08 Message: 5 of 5 "craq" wrote in message ... > or you could use imagescnan (from the file exchange). Then you can either fudge your x and y axes: > > x_plot=log10(x); > y_plot=log10(y); > imagescnan(x_plot,y_plot,apple) > > or use the set(gca...) commands you listed before. > > also, instead of 10.^linspace, you may want to have a look at the function logspace Hi Craq, You are right. I have to use TickLabel to trick the plot ticks so far... But the actual need is to display them with accurate logarithmic ticks. It seems imagesc won't do that for me. Thank you for replying me. Rebecca

Everyone's Tags:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.