Previously, we shared the method for drawing multiple bar charts (Matlab publication-level illustration drawing template – bar chart):

We have also shared the method for drawing partitioned bar charts (Advanced Matlab Plotting Issue 67 – Partitioned Bar Chart):

Partitioned bar charts essentially group the same category (color) parts of multiple bar charts together.
Multiple bar charts are often used to compare the effects of different methods on the same data, while partitioned bar charts are suitable for analyzing the relationships between different data using the same method.
Furthermore, based on the partitioned bar chart, an additional bar can be added after each partition’s bar to represent an additional variable, such as the total.
This article utilizes a self-made BlockBar tool to draw composite bar charts. Let’s first take a look at the finished product:

Special Note: The content of this issue ‘Data + Code’ has been uploaded to the resource group. Friends who join the group can download it themselves. Those in need can follow the public account with the same name 【阿昆的科研日常】 and reply with the keyword 【全家桶】 to see how to join.
1. Data Preparation
This part mainly involves reading the raw data.
% Read data
load data.mat
2. Color Definition
Not using color in plotting is like cooking without salt; it always feels a bit lacking.
However, color matching tests personal aesthetics and requires more attempts.
Here, we directly use the SCI authoritative color library from TheColor color matching tool:
map = TheColor('sci',618);C1 = map(2:2:8,1:3);C2 = map(1:2:7,1:3);


(Click the above image to view the specific functions of TheColor)
Access method: Public account (阿昆的科研日常) reply TC
3. Drawing Composite Bar Chart
Call the ‘CBlockBar’ command to draw the initial composite bar chart.
CBlockBar(data1,data2,C1,C2);hTitle = title('Combined Blocked Bar');hXLabel = xlabel('xaxis');hYLabel = ylabel('yaxis');
4. Detail Optimization
For the aesthetics of the illustration, beautify the details of the coordinate axes:
% Coordinate area adjustment
set(gca, 'Box', 'off', ... % Border
'LineWidth',1,... % Line width
'Layer','top',... % Layer
'XGrid', 'off', 'YGrid', 'off', ... % Grid
'TickDir', 'out', 'TickLength', [.01 .01], ... % Scale
'XMinorTick', 'off', 'YMinorTick', 'off', ... % Minor scale
'XColor', [.1 .1 .1], 'YColor', [.1 .1 .1]) % Axis color
set(gca, 'xticklabel',1:12,'ylim',[0 1400])% Font and font size
set(gca, 'FontName', 'Arial', 'FontSize', 10)
set([hXLabel, hYLabel], 'FontSize', 11, 'FontName', 'Arial')
set(hTitle, 'FontSize', 12, 'FontWeight' , 'bold')% Background color
set(gcf,'Color',[1 1 1])% Add top and right border
xc = get(gca,'XColor');yc = get(gca,'YColor');unit = get(gca,'units');ax = axes( 'Units', unit,... 'Position',get(gca,'Position'),... 'XAxisLocation','top',... 'YAxisLocation','right',... 'Color','none',... 'XColor',xc,... 'YColor',yc);
set(ax, 'linewidth',1,... 'XTick', [],... 'YTick', []);
After the settings are complete, output the image in the resolution and format required by the journal.
%% Image output
figW = figureWidth;
figH = figureHeight;
set(figureHandle,'PaperUnits',figureUnits);
set(figureHandle,'PaperPosition',[0 0 figW figH]);
fileout = 'test';
print(figureHandle,[fileout,'.png'],'-r300','-dpng');

That’s all.
5. Full Package
Currently, the drawing of Matlab composite bar charts 【Data + Code】 has been added to the full package.
The full package plan refers to uploading all related resources released in the past and future to a group. After joining the full package plan, everyone can download all resources in the group anytime, anywhere.

Included in the full package are……
Matlab paper illustration drawing template series (completed, includes 3 versions * 139 classic data charts, reply with the keyword 【139】 to see the individual acquisition method):

Advanced Matlab Plotting Series (complex plotting beyond Matlab’s default plotting, now includes 90 classic data charts):

Personalized Matlab Plotting Series (diversified style plotting, now includes 24 data charts):

Nature/Science Paper Illustration Replication Series (achieving top journal effects with Matlab paper illustrations, now includes 5 data charts):


High-definition Image Collection Series for Top Journals, including Nature high-definition image collection (learning the drawing ideas of Nature, including about 2400 images):

Science high-definition image collection (learning the drawing ideas of Science, over 1000 images):

Matlab Color Supplement Package Series (including color enhancement addcolorplus, 450 common colors colorplus, SCI dedicated color tool Rggsci, and traditional colors from China, Japan, the USA, the UK, and France):




Matlab Research Plotting Premium Toolkit (including gradient color generator/editor ColorMap, professional version gradient color generator ColorMapPro, shadow renderer Shadow, top journal color copy tool ColorCopy, and image data extraction tool Fig2Data):



and the ultimate Matlab color tool TheColor (2 sets):


Reply with the keyword 【全家桶】 in the public account to see how to join.
That’s all.
If you find my sharing helpful, feel free to like, view, and share here. Of course, everyone is also welcome to tip here. The more interaction, the faster the updates~
Disclaimer: All original content of this public account may not be used for any commercial purposes without permission; violators will be prosecuted.