Command 'hold on' does not work for boxplot when overlapping a figure
21 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I've got a boxplot with xlimits from 0.1 to 1.0 and from ylimits from 0 to 1.6.
I want to overlap a plot of just 5 points (plotted as dots) with xlimits from 0.18 to 0.4 and the y values being only 2.0.
However, the hold on function does not seem to work.
Any thoughts of that?
Thank you!
0 comentarios
Respuestas (2)
Abhiram Bhanuprakash
el 26 de Mayo de 2015
Hi Christina,
I think this behaviour is because boxplot resets the axes limits, and you are not setting them back to see both the boxplots.
x = rand(5,1);
y = rand(10,1);
z = rand(15,1);
Xpos = [2 5 12];
group = [repmat(Xpos(1), 5, 1); repmat(Xpos(2), 10, 1); repmat(Xpos(3), 15, 1)];
data=[x;y;z];
figure
boxplot(data, group,'positions', Xpos,'colors','k')
hold on
x =2+ rand(5,1);
y = 2+rand(10,1);
z = 2+rand(15,1);
Xpos = [3 6 12];
group = [repmat(Xpos(1), 5, 1); repmat(Xpos(2), 10, 1); repmat(Xpos(3), 15, 1)];
data=[x;y;z];
boxplot(data, group,'positions', Xpos,'colors','r')
But, I suspected that this could be because the x and y axes limits are different for the second box plot, and thus added the following two lines to the above code:
ylim([0 4])
xlim([0 15])
And voila! I could see both the plots!
From the y axes values which you have mentioned in the question, it looks like this is the issue. So try this out!
Cheers!
Abhiram
0 comentarios
Nancy Usala
el 11 de Jul. de 2017
Hi, I have this 2 plots (1.-boxplot and 2.-lines)
and
I need to put the two plots together , I 'm trying with "hold on" but does not work. Please, can you help me?!
The codes that I used
%% GRAFICS MEAn and LAT
clear all close all
dirdata = 'C:\Users\Amministratore\Desktop\ISAC-CNR\DIAPASON\Diapason Resultados 2006-2012\Resultados 2006-2012 statistic70'; cd(dirdata)
file=xlsread('DustYA vs Lat + pey (70)5y.xls');
AvgDLdD=file(:,12); via=file(:,5);
figure boxplot(AvgDLdD,via);
title('2006-2012 mean(70)5y'); axis ([0 22 0 10]); xlabel('Latitude(0.5 degree)'); ylabel('Dust Impact on Yearly Average PM10 (ug/m3)'); grid on hold on
% plot(puntomean,'s','MarkerEdgeColor','r','MarkerFaceColor','r','MarkerSize',4)
fplot(@(x)(1.8^13)*(x^-8)*10^10,[35 50],'k');%Pey et al 2013 %fplot(@(x)(1.7^13)*(x^-8)*10^10,[35 50],'r');%Pey et al 2013%!!! [Xct,Yct] = fplot(@(x)(1.7^13)*(x^-8)*10^10,[35 50]); plot(Xct,Yct,'r','LineWidth',2) fplot(@(x)(1.6^13)*(x^-8)*10^10,[35 50],'r');%Pey et al 2013%!!!
Thanks!!!
0 comentarios
Ver también
Categorías
Más información sobre Axis Labels en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!