values in graph

  • Follow


Hi,
please help. I need to show data in the plot. For example a histogram. I'd like to see exact count for every column. Exactly my graph is box plot and I'd like to show a value of median of every box. 

Thank you!!!
0
Reply Tobias 12/27/2010 4:26:04 PM

On Dec 27, 11:26=A0am, "Tobias malach" <tmal...@seznam.cz> wrote:
> Hi,
> please help. I need to show data in the plot. For example a histogram. I'=
d like to see exact count for every column. Exactly my graph is box plot an=
d I'd like to show a value of median of every box.
>
> Thank you!!!

-----------------------------------
You can use the text() function to overlay any text you like on your
graph or image.  Be sure to put "hold on" before you call text().  You
can use sprintf() to build up your string from your variables.  For
example

textString =3D sprintf('The value =3D %.2f', myVariable);
hold on;
text(x, y, textString);
0
Reply ImageAnalyst 12/27/2010 5:25:47 PM


ImageAnalyst <imageanalyst@mailinator.com> wrote in message <be4e1a10-da55-4d0a-936a-1bd7591643ee@j25g2000yqa.googlegroups.com>...
> On Dec 27, 11:26 am, "Tobias malach" <tmal...@seznam.cz> wrote:
> > Hi,
> > please help. I need to show data in the plot. For example a histogram. I'd like to see exact count for every column. Exactly my graph is box plot and I'd like to show a value of median of every box.
> >
> > Thank you!!!
> 
> -----------------------------------
> You can use the text() function to overlay any text you like on your
> graph or image.  Be sure to put "hold on" before you call text().  You
> can use sprintf() to build up your string from your variables.  For
> example
> 
> textString = sprintf('The value = %.2f', myVariable);
> hold on;
> text(x, y, textString);

----------------------------------------
Thanks, 
problem of this solution is that i acctually haven't got values of median saved in any variable. function boxplot counts all the values for graph automatically. I think there should be something in object inspector like: show data points, show values or something like this. I believe this must be posible to be done automatically without "prgramming it". 
  
0
Reply Tobias 12/27/2010 6:11:22 PM

On 27/12/10 12:11 PM, Tobias malach wrote:

> Thanks, problem of this solution is that i acctually haven't got values
> of median saved in any variable. function boxplot counts all the values
> for graph automatically. I think there should be something in object
> inspector like: show data points, show values or something like this. I
> believe this must be posible to be done automatically without
> "prgramming it".

You are welcome to continue holding that belief, but I don't think you 
will find any supporting evidence for that belief. The only thing 
built-in is showing data points; anything more like showing medians must 
be programmed. The programming is not necessarily difficult.

You might be interested in looking at the documentation for datacursormode()
0
Reply Walter 12/27/2010 7:31:48 PM

Walter Roberson <roberson@hushmail.com> wrote in message <FQ5So.8431$111.5692@newsfe12.iad>...
> On 27/12/10 12:11 PM, Tobias malach wrote:
> 
> > Thanks, problem of this solution is that i acctually haven't got values
> > of median saved in any variable. function boxplot counts all the values
> > for graph automatically. I think there should be something in object
> > inspector like: show data points, show values or something like this. I
> > believe this must be posible to be done automatically without
> > "prgramming it".
> 
> You are welcome to continue holding that belief, but I don't think you 
> will find any supporting evidence for that belief. The only thing 
> built-in is showing data points; anything more like showing medians must 
> be programmed. The programming is not necessarily difficult.
> 
> You might be interested in looking at the documentation for datacursormode()

--------------
Thanks, as usually i believ it is not difficult. But this is the first time I need to do something like this. You suggest to create boxplot, then count medians, change them to string and assign these strings to boxes in the graph right? 

datacursomode is unfortunately nothing new for me. 

thanks
0
Reply Tobias 12/27/2010 9:16:05 PM

On 27/12/10 3:16 PM, Tobias malach wrote:

> Thanks, as usually i believ it is not difficult. But this is the first
> time I need to do something like this. You suggest to create boxplot,
> then count medians, change them to string and assign these strings to
> boxes in the graph right?

No, someone else suggested that. I did not suggest it because of your 
mention of "object inspector", which suggests that you do not want to 
create permanent information but instead wish to be able to point to an 
arbitrary position in the graph and have information relevant to that 
point come up. That kind of location-dependent temporary information is 
most easily handled with datacursormode() .
0
Reply Walter 12/27/2010 9:40:42 PM

On Dec 27, 1:11=A0pm, "Tobias malach" <tmal...@seznam.cz> wrote:
> Thanks,
> problem of this solution is that i acctually haven't got values of median=
 saved in any variable. function boxplot counts all the values for graph au=
tomatically. I think there should be something in object inspector like: sh=
ow data points, show values or something like this. I believe this must be =
posible to be done automatically without "prgramming it".
-----------------------------------------------------------
Tobias:
Perhaps you should study my demo (first posted as #8 in this thread:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/291696#780914=
)

% IMPORTANT: The newsreader may break long lines into multiple lines.
% Be sure to join any long lines that got split into multiple single
lines.
% These can be found by the red lines on the left side of your
% text editor, which indicate syntax errors, or else just run the
% code and it will stop at the split lines with an error.

clc;    % Clear the command window.
close all;  % Close all figures (except those of imtool.)
imtool close all;  % Close all imtool figures.
clear;  % Erase all existing variables.
workspace;  % Make sure the workspace panel is showing.
fontSize =3D 14;
% Change the current folder to the folder of this m-file.
if(~isdeployed)
	cd(fileparts(which(mfilename)));
end
% Make sample data
x =3D -4:0.4:4;
y =3D randn(10000,1);
% Get histogram
[values, bins] =3D hist(y,x) ;
% Plot it.
bar(bins, values);
numberOfBins =3D length(bins);
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize'));
xlabel('Count', 'fontSize', fontSize);
ylabel('Bin', 'fontSize', fontSize);
title('Histogram', 'fontSize', fontSize);

% Make offsets so they will be centered over the bars.
offsetX =3D -(bins(2) - bins(1))* 0.4;
offsetY =3D 30; % Depends on plot's size on screen.
% Put counts over the bars.
for bin =3D 1 : numberOfBins
	caption =3D sprintf('%d', values(bin));
	text(bins(bin)+offsetX, values(bin) + offsetY,...
		caption, 'fontSize', fontSize);
end

0
Reply ImageAnalyst 12/27/2010 10:10:08 PM

6 Replies
182 Views

(page loaded in 0.121 seconds)


Reply: