Prev: simulation
Next: trapz syntax - any help appreciated
From: Arie Driga on 6 May 2010 04:30 Hi all I have n-set of plot. I would like to plot those into a single graph. Each plot should have a different marker from each other and the legend is written for each data set. I would like to do that in m-file. How can I do that?
From: Arie Driga on 6 May 2010 18:55 "Arie Driga" <a_driga(a)yahoo.com> wrote in message <hrtun3$e0t$1(a)fred.mathworks.com>... > Hi all > > I have n-set of plot. I would like to plot those into a single graph. Each plot should have a different marker from each other and the legend is written for each data set. I would like to do that in m-file. > > How can I do that? Since no one has replied this, I just want to add my m-file: function flowrate2(kin_viscosity, width, min_re, max_re, number_of_points, varargin) Re=linspace(min_re,max_re,number_of_points); n=size(varargin,2); %n2=size(Re2,2); a=zeros(1,n); for i=1:n a (i) = varargin {i};% load vector % l=num2str(a(i)); end Area=width.*a(1,1:n); D=2*width.*a(1,1:n)./(a(1,1:n)+width); b=Re*kin_viscosity; %c=b./D(1,1:n); %D_inverse=1./D(1,1:n); %u_mean=D_inverse'*b u_mean2=bsxfun(@rdivide,b,reshape(D,[],1)); F=bsxfun(@times,u_mean2,reshape(Area,[],1)).*60000; xlswrite('flow_rate',F,'Sheet1'); l=num2str(a,2); Vmin_1=0*Re+(11/240*1.5); Vmin_2=0*Re+2*(11/240*1.5); plot(Re,Vmin_1,'-r',Re,Vmin_2,'-b','LineWidth',2); axis([0 1 0.02 0.3]); xlabel('Reynolds number [-]', 'fontsize', 12, 'fontweight', 'b'); ylabel('Flow rate [l/min]', 'fontsize', 12, 'fontweight', 'b'); hold on grid on plot(Re,F(1:n,:)); %plot(Re,Flow_rate) %fprintf('Variation in Height',height_var); end Problem: I can give multiple input for height, each value will be plotted. I would like to give different marker for each input height as well as the legend for each one of them.
From: Walter Roberson on 6 May 2010 19:07 Arie Driga wrote: > I can give multiple input for height, each value will be plotted. I > would like to give different marker for each input height as well as the > legend for each one of them. The difficulty is that there are a limited number of different marker types available, and no (official) mechanism for defining new marker types. As you do not limit the number of heights, then plausibly you could run out of system-defined markers, and then for the remaining lines, you would have to add the markers to the graph yourself. To do your own markers, set the Marker to be 'none', and then find the coordinates of each point, and "nearby" either line() a shape into existance or text() a character there. Of course, if you go with custom shapes then you are going to need to pre-define the shapes or define some algorithm for computing a new and yet recognizably different shape. I think you'll find you have difficulty coming up with a new recognizable shape somewhere around the 20'th, so you might instead choose to use numbers or letter-combinations (watch out for look-alike characters!) Might I suggest that you consider using the Matlab File Exchange routine plt() ? It can easily manipulate line styles and line color and shapes, to come up with a number of distinct lines. I am not certain how many different combinations are supported; 96 is the number that comes to mind, but my memory is a bit faulty these days.
From: Arie Driga on 6 May 2010 19:35 Walter Roberson <roberson(a)hushmail.com> wrote in message <bZHEn.49$gv4.32(a)newsfe09.iad>... > Arie Driga wrote: > > > I can give multiple input for height, each value will be plotted. I > > would like to give different marker for each input height as well as the > > legend for each one of them. > > The difficulty is that there are a limited number of different marker > types available, and no (official) mechanism for defining new marker > types. As you do not limit the number of heights, then plausibly you > could run out of system-defined markers, and then for the remaining > lines, you would have to add the markers to the graph yourself. > > To do your own markers, set the Marker to be 'none', and then find the > coordinates of each point, and "nearby" either line() a shape into > existance or text() a character there. Of course, if you go with custom > shapes then you are going to need to pre-define the shapes or define > some algorithm for computing a new and yet recognizably different shape. > I think you'll find you have difficulty coming up with a new > recognizable shape somewhere around the 20'th, so you might instead > choose to use numbers or letter-combinations (watch out for look-alike > characters!) > > Might I suggest that you consider using the Matlab File Exchange routine > plt() ? It can easily manipulate line styles and line color and shapes, > to come up with a number of distinct lines. I am not certain how many > different combinations are supported; 96 is the number that comes to > mind, but my memory is a bit faulty these days. Thanks for the reply.. Most likely that I will not go beyond 10 inputs. So how can define the marker and the color? Then to assign the legend for each one?
From: Walter Roberson on 6 May 2010 20:07
Arie Driga wrote: > Most likely that I will not go beyond 10 inputs. So how can define the > marker and the color? Then to assign the legend for each one? markers = '+o*.xsd^v><pbh'; lines = zeros(numheights,1); legstrs = cell(numheights,1); for K = 1:numheights lines(K) = plot(AppropriateValue(:,K), 'Marker', markers(K)); legstrs{K} = sprintf('Something Appropriate #%d', K); hold on end legend(lines(K), legstrs{:}); |