How to reproduce a figure?

5 views (last 30 days)
Tomaszzz
Tomaszzz on 22 Mar 2022
Commented: Tomaszzz on 28 Mar 2022
Hi all,
The below figure is a copy from a journal and I would like to use such a figure to present my own data.
I would like to write a code that will reproduce the below figure or at least have an advice for a methodology to do this so that I can develop it myself. For example, how to make shading between 0.8 and 1 or how to split the graph in three columns.
The points are circle, square and diamond and error bars are std.
Could you help please?

Accepted Answer

Voss
Voss on 22 Mar 2022
Edited: Voss on 22 Mar 2022
f = figure();
ax = axes( ...
'Parent',f, ...
'NextPlot','add');
% grey shading on top:
p = patch( ...
'Parent',ax, ...
'XData',[0 1 1 0], ...
'YData',[0.75 0.75 1 1], ...
'FaceColor',[0.8 0.8 0.8], ...
'EdgeColor','none');
% line separating axes into 3 parts:
gl = line( ...
'Parent',ax, ...
'XData',[1 1 NaN 2 2]/3, ...
'YData',[0 1 NaN 0 1]);
% boxplot() some random data, for instance:
random_data = rand(10,3);
bp = boxplot(random_data);
% rescale the XData of the boxplot objects to be
% centered at 1/6, 1/2, 5/6 instead of 1, 2, 3:
for ii = 1:numel(bp)
set(bp(ii),'XData',(get(bp(ii),'XData')*2-1)/6);
end
% tick labels, etc.:
set(ax, ...
'XLim',[0 1], ...
'YLim',[0 1], ...
'XTick',[1 3 5]/6, ...
'XTickLabel',{'Sag','Frnt','Tran'}, ...
'Layer','top', ...
'FontSize',14);
title('Hip: : LFM R^2');
  3 Comments
Voss
Voss on 22 Mar 2022
You're welcome!
Tomaszzz
Tomaszzz on 28 Mar 2022
Hi @_. I was trying to modify the code for my data but I am failing. I have posted a similar question here https://uk.mathworks.com/matlabcentral/answers/1682344-how-to-produce-a-grouped-errorbars just in case you would like to have a look.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!