### Tags: 100cos, 12pithen, axis, deali, helloi, matlab, maybeeyou, modify, plot, programming, scale, y-axis

# Axis with other scale

On Programmer » Matlab

7,292 words with 6 Comments; publish: Thu, 01 May 2008 20:33:00 GMT; (200187.50, « »)

Hello!

I have tried to modify the y-axis without success. Maybee

you can help me. This is the deal:

I want to plot y(x) = 100cos(x), x = 0:0.1:2pi

Then I want to change the scale on the y axis so it goes

something like this:

y = {1,2,3,4,5,6,7,8,9,10,20,30,40,50,75,100

} i.e. small

scale for low values and large scale for high values

I would say its some kind of mixture between lin and log

scale.

Solution anyone?

*http://matlab.todaysummary.com/q_matlab_4570.html*

All Comments

Leave a comment...

- 6 Comments
- In article <fn86a6$ihr$1.matlab.todaysummary.com.fred.mathworks.com>, a t <atronsen.matlab.todaysummary.com.hotmail.com> wro
te:

>I have tried to modify the y-axis without success. Maybee

>you can help me. This is the deal:

>I want to plot y(x) = 100cos(x), x = 0:0.1:2pi

>Then I want to change the scale on the y axis so it goes

>something like this:

>y = {1,2,3,4,5,6,7,8,9,10,20,30,40,50,75,100

} i.e. small

>scale for low values and large scale for high values

>I would say its some kind of mixture between lin and log

>scale.

Do you want to modify the scale itself, or only the tick

labels and positions? If it is just the tick positions, then

set(gca, 'YTickMode', 'manual', ...

'YTick', {1,2,3,4,5,6,7,8,9,10,20,30,40,50,75,100

})

So you found your solution

What will be your last contribution?

-- Supertramp (Fool's Overture)

#1; Thu, 01 May 2008 20:34:00 GMT

- In article <fn86a6$ihr$1.matlab.todaysummary.com.fred.mathworks.com>, a t <atronsen.matlab.todaysummary.com.hotmail.com> wro
- Hi Walter!
I want to change the y scale so that the ticks becomes like

below. This is because not lin nor log gives me a decent

plot.

Any solution?

roberson.matlab.todaysummary.com.ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in

message <fn87l3$a22$1.matlab.todaysummary.com.canopus.cc.umanitoba.ca>...

> In article <fn86a6$ihr$1.matlab.todaysummary.com.fred.mathworks.com>, a t

<atronsen.matlab.todaysummary.com.hotmail.com> wrote:

>

Maybee

>

> Do you want to modify the scale itself, or only the tick

> labels and positions? If it is just the tick positions,

then

> set(gca, 'YTickMode', 'manual', ...

> 'YTick', {1,2,3,4,5,6,7,8,9,10,20,30,40,50,75,100

})

> --

> So you found your solution

> What will be your last contribution?

> -- Supertramp (Fool's Overture)

#2; Thu, 01 May 2008 20:35:00 GMT

- Hi Walter!
- "Steven Lord" <slord.matlab.todaysummary.com.mathworks.com> wrote in message
<fna6ms$mmd$1.matlab.todaysummary.com.fred.mathworks.com>...

> "a t" <atronsen.matlab.todaysummary.com.hotmail.com> wrote in message

> news:fn9ift$jm3$1.matlab.todaysummary.com.fred.mathworks.com...

like

> Use a slight variation on Walter's suggestion:

>

> % No need to set the YTickMode property; setting the

YTick property

> automatically changes YTickMode to 'manual'

> % Also the *Tick properties accept vectors, not cell

arrays; the *TickLabel

> properties accept cells

> set(gca, 'YTick',

[1,2,3,4,5,6,7,8,9,10,20,30,40,50,75,100

])

> % Make sure we can see all the ticks

> ylim([0 101])

>

> If you want to change just the labels of the ticks, and

not their positions

> on the axes, look at the YTickLabel property.

> --

> Steve Lord

> slord.matlab.todaysummary.com.mathworks.com

>

This partly solved my problem. I get the ticks to change

but I want to change the scale of the whole plot so that

this range y = [1,2,3,4,5,6,7,8,9,10,20,30,40,50,75,100

] is

displayed equidistantly (which means that the cosine

function doesent look like a cosine anymore)

#3; Thu, 01 May 2008 20:36:00 GMT

- "Steven Lord" <slord.matlab.todaysummary.com.mathworks.com> wrote in message
- may I suggest scaling the function values itself (before
plotting)? and _then_ change the ticks as described above?

and how to do that.. hmm.. some kind of squashing/

companding.. there has to be some code for that in MATLAB.

looking..

#4; Thu, 01 May 2008 20:37:00 GMT

- may I suggest scaling the function values itself (before
- In article <fnab1i$3nd$1.matlab.todaysummary.com.fred.mathworks.com>, a t <atronsen.matlab.todaysummary.com.hotmail.com> wrote:
>This partly solved my problem. I get the ticks to change

>but I want to change the scale of the whole plot so that

>this range y = [1,2,3,4,5,6,7,8,9,10,20,30,40,50,75,100

] is

>displayed equidistantly (which means that the cosine

>function doesent look like a cosine anymore)

The generating function for that list is

F(y) =

- 151/16765056000*y^15 + 5483/4843238400*y^14 -

28861/444787200*y^13 + 6521/2903040*y ^12 - 7849141/149688000*y^11

+ 1809653/2073600*y^10 - 1627000309/152409600*y^9 +

132079243/1354752*y^8 - 145523440669/217728000*y^7 +

6220350487/1814400*y^6 - 24321385303/1871100*y^5 +

5075360441/142560*y^4 - 2629925137117/38808000*y^3 +

192527288519/2293200*y^2 - 898885804/15015*y + 18228

Unfortunately what you need is the inverse function of that,

so to map Y = 100*sin(X) into that, you will need to do a

numeric root-finding on Y(K) to find the YM(K) such that

F(YM(K)) = Y(K) and then plot the YM instead of Y.

The mapping was determined in maple:

x -> F15*x^15+F14*x^14+F13*x^13+F12*x^12+F11*

x^11+F10*x^10+F9*x^9+F8*x^8+F7*

x^

7+F6*x^6+F5*x^5+F4*x^4+F3*x^3+F2*x^2+F1*

x+F0;

ys := [1,2,3,4,5,6,7,8,9,10,20,30,40,50,75,100

];

UU := solve({seq(F(K) = ys[K],K=1..16)});

lprint(eval(F(x),UU);

"I will speculate that [...] applications [...] could actually see a

performance boost for most users by going dual-core [...] because it

is running the adware and spyware that [...] are otherwise slowing

down the single CPU that user has today" -- Herb Sutter

#5; Thu, 01 May 2008 20:38:00 GMT

- In article <fnab1i$3nd$1.matlab.todaysummary.com.fred.mathworks.com>, a t <atronsen.matlab.todaysummary.com.hotmail.com> wrote:
- "a t" <atronsen.matlab.todaysummary.com.hotmail.com> wrote in message
news:fnab1i$3nd$1.matlab.todaysummary.com.fred.mathworks.com...

> "Steven Lord" <slord.matlab.todaysummary.com.mathworks.com> wrote in message

> <fna6ms$mmd$1.matlab.todaysummary.com.fred.mathworks.com>...

*snip*

> This partly solved my problem. I get the ticks to change

> but I want to change the scale of the whole plot so that

> this range y = [1,2,3,4,5,6,7,8,9,10,20,30,40,50,75,100

] is

> displayed equidistantly (which means that the cosine

> function doesent look like a cosine anymore)

% Set up a test axes

axis([-1 1 -1 1 -1 1]);

x1 = -1:0.25:1;

% Note that nothing requires the tick locations and the tick labels to be

the same ...

set(gca, 'XTick', x1, 'XTickLabel', sprintf('%1.4f|', exp(x1)))

xlabel('X');

% or even related ...

set(gca, 'YTick', x1, 'YTickLabel', sprintf('%1.4f|', rand(size(x1))))

ylabel('Y')

% Indeed, the labels are not required to be numbers

set(gca, 'ZTick', x1, 'ZTickLabel', {'A','B','C','D','E','F','G','H','I'});

zlabel('Z')

http://www.mathworks.com/access/hel...ckLab

Steve Lord

slord.matlab.todaysummary.com.mathworks.com

#6; Thu, 01 May 2008 20:39:00 GMT

- "a t" <atronsen.matlab.todaysummary.com.hotmail.com> wrote in message