Hi all, I am trying to get the boxplot for Time (HH:MM:SS) and day name data but unable to get the required plot. In detail, I would like to get the Boxplot in terms of days, (Monday to Sunday). I have attached the sample data and any help in this regard is highly appreciated.

3 Kommentare

Cris LaPierre
Cris LaPierre am 17 Apr. 2021
How should the median, interquartile range, and outliers be determined from your data?
Could you show us what the expected chart should look like?
Ganesh Naik
Ganesh Naik am 18 Apr. 2021
Hi Cris thanks for your response. I have managed to get box plot using command "boxplot(x,y)" for similar set of data where column A data (please refer to the figure) were the same (x -data) but column B data were numbers. For that I have got the plot (attached here). But now, I am not able to get the boxplot for the time (HH:MM:SS) data. I can easily do the box plot if column B contains numbers or decimals. It is also demonstrated for Matlab 'carsmall" data set as an example. So any help in getting the boxplot for time data (HH:MM:SS) would be highly appreciated.
Cris LaPierre
Cris LaPierre am 18 Apr. 2021
Yes, with numeric data, you can calculate medians and standard deviations. It looks like your data is a character array, meaning it is text. See Jonas' suggestion below.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Jonas
Jonas am 18 Apr. 2021

0 Stimmen

i suggest to convert you time (Hour : Minute : Seconds) to seconds using
[~, ~, ~, H, MN, S]=datevec('14:35:22','HH:MM:SS');
MN=MN+60*H;
S=S+MN*60;
then doing you boxplot thing and then converting your boxplot y labels back to a timestring

4 Kommentare

Ganesh Naik
Ganesh Naik am 19 Apr. 2021
Hi Jonas, thanks for your answer, I have managed to get the Box plot using your method. Is there any quick way to label the "Y-axis" data (see the pic) in terms of HH:MM:SS?
Jonas
Jonas am 19 Apr. 2021
just get your yticks, calculate hours, minutes and seconds, put it in a string and then set your ylabels to the strings generated
maybe this can help in the process https://de.mathworks.com/matlabcentral/answers/375392-convert-seconds-to-time
Jonas
Jonas am 19 Apr. 2021
or the other way around: if you have specific times you want to see, calculates them as seconds, set the values as yticks and then set the ylabels to the times you wanted
Ganesh Naik
Ganesh Naik am 20 Apr. 2021
Hi Jonas, thanks for your help. I am going to accept the answer.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 17 Apr. 2021

Kommentiert:

am 20 Apr. 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by