Thread Subject: Suppress Plot Unit Modifiers

Subject: Suppress Plot Unit Modifiers

From: David Doria

Date: 29 Mar, 2008 17:30:05

Message: 1 of 7

Sometimes when I make a plot, if the x tic values are 1000,
2000 etc, it will show them as 1, 2, etc

and then put
x10^3

in the bottom right of the plot.

1) is there a way to set this location? It usually ends up
in an awkward spot, I'd like it inline with the xlabel

2) can you tell it "dont put this unit modifier"?

Thanks!

David

Subject: Suppress Plot Unit Modifiers

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

Date: 29 Mar, 2008 18:00:16

Message: 2 of 7

In article <fsluas$gr0$1@fred.mathworks.com>,
David Doria <daviddoria@gmail.com> wrote:
>Sometimes when I make a plot, if the x tic values are 1000,
>2000 etc, it will show them as 1, 2, etc

>and then put
>x10^3

>in the bottom right of the plot.

>1) is there a way to set this location? It usually ends up
>in an awkward spot, I'd like it inline with the xlabel

I do not know of any way to control the position. It is not in
any property that I have been able to find.


>2) can you tell it "dont put this unit modifier"?

set(gca,'XTickLabel',num2str(get(gca,'XTick').'))
--
  "The whole history of civilization is strewn with creeds and
  institutions which were invaluable at first, and deadly
  afterwards." -- Walter Bagehot

Subject: Suppress Plot Unit Modifiers

From: David Doria

Date: 29 Mar, 2008 18:25:03

Message: 3 of 7

in this example:

x=1:1e5;
y=x.^2;
plot(x,y)
set(gca,'XTickLabel',num2str(get(gca,'XTick').'))

the axis labels become the actual values (ie 90000, etc).

Is there a way to extract the multiplier so you can divide
by it and get just 9, etc.

ie.

set(gca,'XTickLabel',num2str(get(gca,'XTick').'./MULTIPLIER))

Thanks,

David

Subject: Suppress Plot Unit Modifiers

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

Date: 29 Mar, 2008 18:40:18

Message: 4 of 7

In article <fsm1hv$dhm$1@fred.mathworks.com>,
David Doria <daviddoria@gmail.com> wrote:
>in this example:

>x=1:1e5;
>y=x.^2;
>plot(x,y)
>set(gca,'XTickLabel',num2str(get(gca,'XTick').'))

>the axis labels become the actual values (ie 90000, etc).

>Is there a way to extract the multiplier so you can divide
>by it and get just 9, etc.

xticks = get(gca,'XTick').';
pow10 = 10^floor(log10(min(xticks(:))));
set(gca,'XTickLabel',num2str(xticks ./ pow10));
--
   "Any sufficiently advanced bug is indistinguishable from a feature."
   -- Rich Kulawiec

Subject: Suppress Plot Unit Modifiers

From: David Doria

Date: 29 Mar, 2008 19:08:01

Message: 5 of 7

well in this case since it starts at 0 I think we'd have to
use max() instead of min(), but I was wondering if there was
a more direct method to access what matlab has decided to be
the best scale factor , ie

get(gca, 'ScaleFactor') or something

Subject: Suppress Plot Unit Modifiers

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

Date: 30 Mar, 2008 03:13:18

Message: 6 of 7

In article <fsm42h$4gq$1@fred.mathworks.com>,
David Doria <daviddoria@gmail.com> wrote:
>well in this case since it starts at 0 I think we'd have to
>use max() instead of min(),

But then if your data runs (say) 8000 9000 10000 11000
then the output would be .8 .9 1 1.1 rather than 8 9 10 11 .
You could take the min() of the non-zero values, perhaps.


>but I was wondering if there was
>a more direct method to access what matlab has decided to be
>the best scale factor , ie

>get(gca, 'ScaleFactor') or something

If there is then it is undocumented and in some very hidden property.

But if you have a plot that you know it has happened to, then
you could get() the XTickLabel, str2double() the last of those,
get() the XTick, take the last of those, divide by the computed label,
and the result should be the scale factor that was involved.

Hmmm, for that matter,

set(gca, 'XTickLabel', get(gca, 'XTickLabel'))

might work!
--
  "I think Walter was a very smart man." -- Gene Autry

Subject: Suppress Plot Unit Modifiers

From: David Doria

Date: 30 Mar, 2008 03:34:01

Message: 7 of 7

haha good idea - that'll do it!

Tags for this Thread

Add a New Tag:

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com