Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: change data format in plot window?

Subject: change data format in plot window?

From: Holger Kirchhoff

Date: 08 May, 2008 08:53:03

Message: 1 of 3

Hi,

I could imagine that other people had this problem, but I
did not find anything similar by using the newsgroup search:

Is there a way to change the format the data is displayed in
the plot window? If I plot vectors with more than 10^5
elements and want to find out an exact index position by
zooming into the plot, the numeric format is limited to 4
digits after the decimal point (like the 'short e'-format in
the command window), and it is not directly possible to
determine the exact index of a data point.
This is especially annoying when you display vectors with
even more elements. E.g. a displayed index of "1.2345 x
10^8" could be any index between 123450000 and 123459999.

If it is not possible to change the data format of the axes,
is it optionally possible to change the data format of the
data cursor? I know, that it is possible to export the value
of the data cursor to a workspace-variable and display it
there in your favorite format, but if you want to check many
data points quickly, this becomes very laborious.

Any suggestions?

Holger

Subject: Re: change data format in plot window?

From: helper

Date: 08 May, 2008 10:48:03

Message: 2 of 3

"Holger Kirchhoff" <holkir@cs.tu-berlin.de> wrote in
message <fvuf1f$4g5$1@fred.mathworks.com>...
> Hi,
>
> I could imagine that other people had this problem, but I
> did not find anything similar by using the newsgroup
search:
>
> Is there a way to change the format the data is displayed
in
> the plot window? If I plot vectors with more than 10^5
> elements and want to find out an exact index position by
> zooming into the plot, the numeric format is limited to 4
> digits after the decimal point (like the 'short e'-format
in
> the command window), and it is not directly possible to
> determine the exact index of a data point.
> This is especially annoying when you display vectors with
> even more elements. E.g. a displayed index of "1.2345 x
> 10^8" could be any index between 123450000 and 123459999.
>
> If it is not possible to change the data format of the
axes,
> is it optionally possible to change the data format of the
> data cursor? I know, that it is possible to export the
value
> of the data cursor to a workspace-variable and display it
> there in your favorite format, but if you want to check
many
> data points quickly, this becomes very laborious.
>
> Any suggestions?
>
> Holger


After plotting your data, try this convoluted command which
will print 15 decimal places in the data cursor:

set(datacursormode,'UpdateFcn',@(Y,X){sprintf('X: %
0.15f',X.Position(1)),sprintf('Y: %0.15f',X.Position(2))})

Subject: Re: change data format in plot window?

From: Steven Lord

Date: 08 May, 2008 13:26:27

Message: 3 of 3


"Holger Kirchhoff" <holkir@cs.tu-berlin.de> wrote in message
news:fvuf1f$4g5$1@fred.mathworks.com...
> Hi,
>
> I could imagine that other people had this problem, but I
> did not find anything similar by using the newsgroup search:
>
> Is there a way to change the format the data is displayed in
> the plot window? If I plot vectors with more than 10^5
> elements and want to find out an exact index position by
> zooming into the plot, the numeric format is limited to 4
> digits after the decimal point (like the 'short e'-format in
> the command window), and it is not directly possible to
> determine the exact index of a data point.
> This is especially annoying when you display vectors with
> even more elements. E.g. a displayed index of "1.2345 x
> 10^8" could be any index between 123450000 and 123459999.

Use the zoom mode object's ActionPostCallback function to adjust the
XTickLabel property of the axes after zooming.

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/zoom.html


x = 1e5:1e4:3e5;
y = (x/1e4)*5;
plot(x, y);
zoom('on');
zM = zoom(gcf);
set(zM, 'ActionPostCallback', ...
    @(figh, eventobj) set(eventobj.Axes, 'XTickLabel', ...
    sprintf('%5.3f|', get(eventobj.Axes, 'XTick'))));


> If it is not possible to change the data format of the axes,
> is it optionally possible to change the data format of the
> data cursor? I know, that it is possible to export the value
> of the data cursor to a workspace-variable and display it
> there in your favorite format, but if you want to check many
> data points quickly, this becomes very laborious.

See the last example on the documentation page for DATACURSORMODE:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/datacursormode.html

--
Steve Lord
slord@mathworks.com


Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
updatefcn helper 08 May, 2008 06:50:18
data cursor helper 08 May, 2008 06:50:18
display Holger Kirchhoff 08 May, 2008 04:55:20
axes Holger Kirchhoff 08 May, 2008 04:55:19
data cursor Holger Kirchhoff 08 May, 2008 04:55:19
data format Holger Kirchhoff 08 May, 2008 04:55:18
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
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 Disclaimer prior to use.
Related Topics