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:
non-linear scale in axes / imagesc

Subject: non-linear scale in axes / imagesc

From: Christoph Meyer

Date: 14 Jan, 2008 13:11:02

Message: 1 of 7

Hi together,

I have a plot of a 2D-matrix using imagesc.
The x-axis in the plot represents the time. The problem is, that at some
points the scale is changing, because there is a slow motion part.

It is possible to use a non-linear scaling for an axis?

Example: with [...] = matrix element in plot


Normal scaling
[----][----][----][----][----][----]
[----][----][----][----][----][----]
[----][----][----][----][----][----]
[----][----][----][----][----][----]
[----][----][----][----][----][----]
[----][----][----][----][----][----]


With slow-motion:
[----][----][----][-][-][----][----]
[----][----][----][-][-][----][----]
[----][----][----][-][-][----][----]
[----][----][----][-][-][----][----]
[----][----][----][-][-][----][----]
[----][----][----][-][-][----][----]
                    here

Subject: non-linear scale in axes / imagesc

From: Volkan

Date: 14 Jan, 2008 17:58:03

Message: 2 of 7


>
> It is possible to use a non-linear scaling for an axis?
>

Yes but it's either linear of log, and with no application
to image display.

Yet you can interpolate your image according to recording
speed. (Tighter sampling during fast recording, so that time
difference between each sample is constant).

interp1 will do the trick if you apply it to each row.

Volkan

Subject: non-linear scale in axes / imagesc

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 14 Jan, 2008 18:04:20

Message: 3 of 7

In article <5v15baF1kakhfU1@mid.dfncis.de>,
Christoph Meyer <christoph.meyer@rwth-aachen.de> wrote:
>It is possible to use a non-linear scaling for an axis?

Other than log vs linear, you pretty much need to override
*Tick and *TickMode and *TickLabel and *TickLabelMode

I seem to recall a couple of months ago someone mentioning a FEX
contribution that at least handled discontinuous axis labelling;
something like that might work for your situation.
--
We regret to announce that sub-millibarn resolution bio-hyperdimensional
plasmatic space polyimaging has been delayed until the release
of Windows Vista SP2.

Subject: non-linear scale in axes / imagesc

From: Volkan

Date: 14 Jan, 2008 18:25:04

Message: 4 of 7


> Other than log vs linear, you pretty much need to override
> *Tick and *TickMode and *TickLabel and *TickLabelMode
>
Those will only change the labels on the axis, not the way
the image is displayed.

Volkan

Subject: non-linear scale in axes / imagesc

From: Christoph Meyer

Date: 14 Jan, 2008 19:40:02

Message: 5 of 7

Volkan schrieb:
>> Other than log vs linear, you pretty much need to override
>> *Tick and *TickMode and *TickLabel and *TickLabelMode
>>
> Those will only change the labels on the axis, not the way
> the image is displayed.
>
> Volkan

Yes - that's the problem.

...and I don't want to change the matrix, via interpolating or duplicate
columns, but I think I have to so, if there is no other possibility.

Thanks till now

Christoph

Subject: non-linear scale in axes / imagesc

From: Adam A

Date: 2 Jun, 2010 11:35:04

Message: 6 of 7

> It is possible to use a non-linear scaling for an axis?
> Example: with [...] = matrix element in plot
>
> Normal scaling
> [----][----][----][----][----][----]
> [----][----][----][----][----][----]
> [----][----][----][----][----][----]
> [----][----][----][----][----][----]
> [----][----][----][----][----][----]
> [----][----][----][----][----][----]
>
> With slow-motion:
> [----][----][----][-][-][----][----]
> [----][----][----][-][-][----][----]
> [----][----][----][-][-][----][----]
> [----][----][----][-][-][----][----]
> [----][----][----][-][-][----][----]
> [----][----][----][-][-][----][----]


In case anyone else is looking for a way to do this (as I was), non-linear axes can be plotted using pcolor instead of imagesc. For example:

>> x = [1,3,4,4.5,5,5.25,5.5,6,7,8];
>> y = [2,3,4,4.5,4.75,5,5.25,5.5,6,7];
>> z = rand(10);
>> pcolor(x,y,z)

Subject: non-linear scale in axes / imagesc

From: Tristan

Date: 4 Nov, 2011 15:42:28

Message: 7 of 7

Thank you for posting the 'workaround', this is great. That problem gave me a headache..
Do you also know a way to center the xaxis ticklabels on the colored fields? They come out at the lines for me, and I can't think of a way to offset them (adding a constant doesn't work because of the nonlinearity..)

best #
Tristan

"Adam A" wrote in message <hu5fl8$4kd$1@fred.mathworks.com>...
> > It is possible to use a non-linear scaling for an axis?
> > Example: with [...] = matrix element in plot
> >
> > Normal scaling
> > [----][----][----][----][----][----]
> > [----][----][----][----][----][----]
> > [----][----][----][----][----][----]
> > [----][----][----][----][----][----]
> > [----][----][----][----][----][----]
> > [----][----][----][----][----][----]
> >
> > With slow-motion:
> > [----][----][----][-][-][----][----]
> > [----][----][----][-][-][----][----]
> > [----][----][----][-][-][----][----]
> > [----][----][----][-][-][----][----]
> > [----][----][----][-][-][----][----]
> > [----][----][----][-][-][----][----]
>
>
> In case anyone else is looking for a way to do this (as I was), non-linear axes can be plotted using pcolor instead of imagesc. For example:
>
> >> x = [1,3,4,4.5,5,5.25,5.5,6,7,8];
> >> y = [2,3,4,4.5,4.75,5,5.25,5.5,6,7];
> >> z = rand(10);
> >> pcolor(x,y,z)

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