help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bar chart with error bars?


From: Bill Denney
Subject: Re: Bar chart with error bars?
Date: Thu, 17 Jul 2008 07:15:42 -0400
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)

address@hidden wrote:
Henry, many thanks for your reply!

I have tried that. Then there is no bar chart anymore.

Here is a snippet of my code:

array=dlmread("testfile2.csv",",") % there are 2 rows and 6 columns of example 
data
% data in columns, cols 1,3,5 are the values to be plotted as bars, % cols 2,4,6 contain dy for the error bars
columns=[]
bars=[]

for i=1:3
columns=[columns,array(:,2*i-1)] % isolate data for bars
bars=[bars,array(:,2*i)]         % isolate data for error bars
endfor

newplot()
colormap winter;

bar([columns])
hold on
errorbar([columns],[bars])
title('Title XYZ','Fontsize',16);
ylim([0,10]) % yaxis neu setzen
xlim([0,10])
legend('condition 1','condition 2','condition 3')
ylabel('arbitrary units')


when the % before "bar" is removed (and the "errorbars" line is commented out), 
then a bar chart with 2 sets of bars (3 bars per set)
is displayed. If the code is run as shows, I get 3x2 plotted points with errer 
bars.
When both lines are executed, first I see a plot with the axes messed up (xlim 
and ylim are ignored), then I see another plot with correct axes, but no 
columns (as when the bar command is not run at all)

Any clues?
You need to add a hold on so that when a new plot is added, you keep what was already on the plot (see above).

Have a good day,

Bill


reply via email to

[Prev in Thread] Current Thread [Next in Thread]