Create a boxchart with half-boxes
古いコメントを表示
Hi,
i am trying to generate a boxchart with halfboxes to compare 2 datasets. Unfortunately there is no attribute to create a half-box in the boxchart function. so my idea was to plot 2 times the same dataset and shift them that they overlap and then make one boxplot completly white. You can see the results in the pictures. Now i want to fuse these two plots but i am facing the problem that when i generate a plot that consists both figures the white boxes are in foreground. does anyone have an idea how to do this? i am also open to other solutions.
thanks in advance
Joel


採用された回答
その他の回答 (1 件)
Austin M. Weber
2024 年 2 月 25 日
編集済み: Austin M. Weber
2024 年 2 月 25 日
Since there is not already a built-in function for making "half" box plots, it might be beneficial to to write your own function (in case you want to make more of these plots in the future).
I have made a relatively simple function for you to use/modify to your needs (see attached). Just note that the approach I took was not to make regular boxchart objects, but rather I have written the function to plot all of the features of the boxplots using the rectangle function. Below is an example of how it works:
% Create two data arrays with the same number of columns
rng(1) % <-- for reproducibility
data1 = normalize(randn(30,10),'Range',[0.05 0.95]);
rng(2) % <-- change RNG seed so that the second data array is different from the first
data2 = normalize(randn(30,10),'Range',[0.05 0.95]);
% Plot the data
h = halfboxplot(data1,data2);
I also added documentation to the function, which you can view by typing the following into your command window:
doc halfboxplot
Feel free to modify the function to fit your needs. I might try to improve this function later on and add it to the File Exchange. If I do I will let you know.
カテゴリ
ヘルプ センター および File Exchange で Descriptive Statistics and Visualization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


