How can I set the axis scale?

I want to build a figure like the one below.
but now it's like:
My code is:
surf(X,Y,Z);
set(gca,'xtick',[4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384]);
set(gca,'ytick',[64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288]);
how can I set the distance of each tick equal to each other?

2 commentaires

Stephen23
Stephen23 le 14 Nov 2015
Modifié(e) : Stephen23 le 16 Nov 2015
To get the correct binary prefixed or SI prefixed numbers you can use my FEX submissions num2bip and num2sip:
They very simple to use, and offer control over significant digits, trailing zeros and the prefix symbol/name.
Binary prefixes:
>> num2bip(10240)
ans = '10 Ki'
>> num2bip(10240,4,true)
ans = '10 kibi'
And for SI:
>> num2sip(10000)
ans = '10 k'
>> num2sip(10000,4,true)
ans = '10 kilo'
dpb
dpb le 15 Nov 2015
How nice a little utility, Stephen...

Connectez-vous pour commenter.

Réponses (2)

dpb
dpb le 14 Nov 2015
Modifié(e) : dpb le 14 Nov 2015

0 votes

The original appears to have been plotted by creating the datapoints at the locations 2^N then plotted versus ordinal number, not the actual value. Then the ticks are labelled to reflect the numeric values.
Try
surf(Z)
instead which will plot against 1:length(x) and 1:length(y) by default. Then adjust the tick marks based on how many points you actually have to be at the correct alignment of which value corresponds; you don't say how big your two vectors are.
BTW, to write the tick labels, you can use
set(gca,'xticklabel',2.^[0:12].');
set(gca,'yticklabel',2.^[2:14].');
and Matlab will translate. You may want to be more specific in controlling formatting, though, in which case you can use num2str to force a given format (like for values such as 8192 and greater you can write as '8K', etc., as in the original).
Oh, also, to more or less duplicate the original,
set(gca,'zscale','log')
to place the vertical axis in log coordinates which will spread out the small stuff.
May also fine
axis equal
pleasing; that'll be a "see what happens" with/without sorta' thing but I'm guessing it'll help the presentation.
the cyclist
the cyclist le 14 Nov 2015

0 votes

I'm not 100% certain I understand your question, but I think a couple things that might help you are to change the axes to logarithmic:
set(gca,'XScale','log')
set(gca,'YScale','log')
set(gca,'ZScale','log')
and then possibly set the tick positions exactly how you want
set(gca,'XTick',[MATLAB vector of tick positions goes here])

Catégories

En savoir plus sur Object Containers dans Centre d'aide et File Exchange

Tags

Modifié(e) :

le 16 Nov 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by