I plotted a simple data matrix
39 135 249 1 91 8 28 0 0 74 17 65 560
69 0 290 26 254 88 31 0 18 53 4 63 625
66 186 344 0 9 0 0 0 18 54 0 74 554
80 41 393 0 0 0 2 0 6 51 0 65 660
271 112 511 1 0 274 0 0 0 0 16 48 601
88 194 312 0 110 0 0 0 44 13 2 76 624
198 147 367 0 15 0 0 3 9 44 3 39 590
using a standard boxplot (i.e. where whiskers extend 1.5 x IRQ from Q1 and Q3). Each column is a variable, each row an observation.
Nevertheless I obtained two different graphics using R (RStudio 1.0.44) and Matlab2018. In particular, whiskers extend in a different way.
In Matlab I'm using the following code:
% clearing workspace
clear all;
close all;
clc;
%entering in current directory where I find the txt data file
tmp = matlab.desktop.editor.getActive;
cd(fileparts(tmp.Filename));
clear tmp;
%reading data
df = readtable('pippo.txt', 'Delimiter', '\t', 'ReadVariableNames',false);
df = table2array(df)
figure(1);
boxplot(df(:, 1:end-1), 'Whisker', 1.5);
ylim([0 600]);
which produces the following graph:
In R I'm using the following code:
rm(list = ls())
# getting the current directory
working_dir <-dirname(rstudioapi::getActiveDocumentContext()$path)
# setting the working directory where I finf the txt file with data
setwd(working_dir)
df <- read.table("pippo.txt")
jpeg('r_boxplot.jpg')
boxplot(df[,1:12], las=2, ylim=c(0,600), range=1.5)
dev.off()
which produces the following graph:
Observation 1: if I omit the parameters 'whiskers' and 'range' from both scripts I obtain the same graphics; it is expected as 1.5 seems to be the default whiskers value.
Observation 2: both matlab and R seem to read data in the correct way, I mean both workspaces visualise the same matrix
What Am I missing? Which graph should I trust?