Thread Subject: Automatically position annotation on bar graph

Subject: Automatically position annotation on bar graph

From: Gunny

Date: 18 Jun, 2009 20:15:04

Message: 1 of 2

I could to with some help.
I have created a function which creates a number of subplots based on a user selection.
The subplots are bar graphs.
The y axis is normalised data.
The x-axis is is the observations.
I would like to place a text box with the absolute vaue on top of each bar graph.

Because the bar gaphs are varying height I don't know how to calculate the position of the textbox. Once the position is calculate how do code the reference to the absolute value to put in the text box?
Below is the code to generate the subplots.

for i=1:NPlotsWanted

    subplot(x,y,i),bar(cell2mat(store(2:end-1,ave_index(i)+1)));
    xlabel('Month','fontsize',8);
    ylabel('Normalised DTC count per month','fontsize',8);
    axis([0 noOfDatas+1 0 0.05]);
    legend(store(1,ave_index(i)+1),'location','NorthOutside','FontSize',8);
    set(gca,'XTickLabel', months); % labels Xticks with months.

end

Thanks, Gunny

Subject: Automatically position annotation on bar graph

From: vedenev

Date: 19 Jun, 2009 08:56:44

Message: 2 of 2

Use text function. Aslo you can get bar object hendle. See example:

h=bar([1 2 3]);
x=get(h,'Xdata');
y=get(h,'Ydata');
for xc=1:length(x)
    text(x,y+0.2,['y=' num2str(y)]);
end

---------------------------------------------
Physics teacher toolbox for Matlab project:
http://physics-toolbox.tripod.com/
vedenev@ngs.ru

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
bar subplot ann... Gunny 18 Jun, 2009 16:19:05
rssFeed for this Thread

Contact us at files@mathworks.com