How can I plot a histogram and line on the same plot in MATLAB 7.11 (R2010b)?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 9 Sep. 2010
Bearbeitet: Paul
am 1 Apr. 2016
I would like to plot both a histogram and a line on the same plot. I have tried using the 'hold on' command, but the scales of the plots are quite different. I would like them to be plotted with separate scales.
Akzeptierte Antwort
MathWorks Support Team
am 9 Sep. 2010
It is possible to plot to lines with separate scales using the PLOTYY command. Once could get the handle to an axis generated by PLOTYY and replace the line plot with a histogram. After plotting the histogram, the y-axis can be rescaled as appropriate. the following code demonstrates this:
x1=1:10;
y1=10*rand(1,1000);
x=1:10;
y=rand(1,10);
axes=plotyy(x,y,x,y);
hold on
hist(axes(1),y1,x1);
ylim(axes(1),'auto');
set(axes(1),'ytickmode','auto');
hold off
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!