MATLAB: Plot and hist in matlab MATLAB please anybody answer me How can I get two plot in one graph using bar or hist or plot and how can I use ((hold and grid command)) with plot and hist Thanks in advance Best Answer Two histograms:x = -2.9:0.1:2.9;y = randn(10000,1);hist(y,x) h = findobj(gca,'Type','patch');set(h,'FaceColor','r','EdgeColor','w')z = randn(size(y))/3;hold on % make sure next one shows up.hist(z,x) Related SolutionsMATLAB: Overlaying histogram with lines and not bars did you want something likex = 5+2*randn(1000,1);h = histc(x,(0:9));stem(h,'b')or likeplot(h,(0:9)) MATLAB: Can HIST take parameters such as FaceColor and EdgeColor As a workaround, you can use the following example code as a guide:% Create some sample datax = -2.9:0.1:2.9;y = randn(10000,1);% Exploit the use of HIST where we return data instead of a plot [n1,x1]=hist(y,x);[n2,x2]=hist(y+6,x+6);% Use the output of HIST to create BAR plots% Note that this exploits the undocumented 'hist' option, used solely by HIST% It is not recommended that you rely on this behavior, but rather you use it as a workaround% Return handles on these calls so we can manipulate them laterh1=bar(x1,n1,'hist');hold onh2=bar(x2,n2,'hist');% Now just modify the color of one of the BAR plotsset(h2,'facecolor','red') Related QuestionWhat if I need both the data and the plot of a histogramPlot using for loopHow to plot a histogram as a curve
Best Answer