Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
imagesc with logarithmic data

Subject: imagesc with logarithmic data

From: Philipp Steffen

Date: 23 Feb, 2011 21:56:06

Message: 1 of 5

Hi all,

I would like to plot values using imagesc, but one of the 2 axes is logarithmic. If I run the following Warnings occur and imagesc does not display anything except the axes:

data=[1,2,3;2,3,4;4,5,6]
x=[0.1,1,10]
y=[1,2,3]

figure
imagesc(x,y,data);
axis xy
set(gca,'XScale','log')

Is there any way to achieve this?

Thanks a lot,

Philipp

Subject: imagesc with logarithmic data

From: ImageAnalyst

Date: 23 Feb, 2011 22:01:42

Message: 2 of 5

Philipp:
Perhaps you're confused.
imagesc does not plot anything - it displays images.
Maybe you want plot(), loglog(), or semilogy().

Subject: imagesc with logarithmic data

From: Philipp Steffen

Date: 23 Feb, 2011 22:15:07

Message: 3 of 5

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <30e41095-c87f-4648-8fb4-f652d42ef3e8@a8g2000pri.googlegroups.com>...
> Philipp:
> Perhaps you're confused.
> imagesc does not plot anything - it displays images.
> Maybe you want plot(), loglog(), or semilogy().

Hi ImageAnalyst,
i know that imagesc is generally used to display images. On the other hand it is an easy way to display a 3 dimensional data set as a heatmap and i wanted to use it exactly for that purpose. I just figured out that you can achieve something somehow similar using surf. If you then rotate the surface plot to have a 2 dimensional view from top you can appreciate somehow how I would like the plot to look like although in this case the color represents the slope between adjacent datapoints rather than their values.
Am I correct in assuming that there is now standard way of achieving this?
Best,

Philipp

Subject: imagesc with logarithmic data

From: ImageAnalyst

Date: 23 Feb, 2011 23:07:32

Message: 4 of 5

You say surf achieves something "similar" to what you want. But I
don't know what you want *exactly* so I guess I'd just say go with
surf().

Subject: imagesc with logarithmic data

From: Steven_Lord

Date: 24 Feb, 2011 17:58:55

Message: 5 of 5



"Philipp Steffen" <philipp.steffen@imba.oeaw.ac.at> wrote in message
news:ik3vpm$dqr$1@fred.mathworks.com...
> Hi all,
>
> I would like to plot values using imagesc, but one of the 2 axes is
> logarithmic. If I run the following Warnings occur and imagesc does not
> display anything except the axes:
>
> data=[1,2,3;2,3,4;4,5,6]
> x=[0.1,1,10]
> y=[1,2,3]
>
> figure
> imagesc(x,y,data);
> axis xy
> set(gca,'XScale','log')
>
> Is there any way to achieve this?

Yes. You will need to change your x vector. How can you display a pixel
centered at (0, 1) when the X axis is in logarithmic scale? [Hint: what is
log(0)? Can you display that coordinate on an axes?]

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

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.

Contact us