File Exchange

image thumbnail


version (311 KB) by Oleg Komarov
Plot correlation matrix as a schemaball


Updated 16 Feb 2017

From GitHub

View Version History

View license on GitHub

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Plots correlation matrix as a schemaball.

- Base demo

- Supply your own correlation matrix (only lower off-diagonal triangular part is considered)
x = rand(10).^3;
x(:,3) = 1.3*mean(x,2);

- Supply custom labels as ['aa'; 'bb'; 'cc'; ...] or {'Hi','how','are',...}
schemaball(x, repmat(('a':'j')',1,2))
schemaball(x, {'Hi','how','is','your','day?', 'Do','you','like','schemaballs?','NO!!'})

- Customize curve colors
schemaball([],[],[1,0,1;1 1 0])

- Customize node color

- Customize manually other aspects
h = schemaball;
set(h.l(~isnan(h.l)), 'LineWidth',1.2)
set(h.s, 'MarkerEdgeColor','red','LineWidth',2,'SizeData',100)
set(h.t, 'EdgeColor','white','LineWidth',1)

For details see help

Cite As

Oleg Komarov (2021). okomarov/schemaball (, GitHub. Retrieved .

Comments and Ratings (27)

Philipp Holz

Christoph Guem

Very nice work! The degree of custumization is well defined.

Woonhee Kim

Luke X

Nice plot! The node colors adds a nice level of complexity.

Arun Kumar

Bernardo Coutinho

Paolo Inglese


I'd like to change the node colors according to known categories, but can't figure out logic behind the 'CData' of the scatter plot part of the graph. E.g. with a 128X128 matrix:

h.s.CData(1,:) = [1 0 0] % Changes color of node # 101
h.s.CData(2,:) = [1 0 0] % Changes color of node # 97
h.s.CData(3,:) = [1 0 0] % Changes color of node # 100
h.s.CData(4,:) = [1 0 0] % Changes color of node # 26

Text seems to be in order, anybody know how to deal with the scatter plot?

Vitali Alexeev

To plot on the white background, change the following two lines in schemaball.m file:

A) Change
ccolor = hsv2rgb([repmat(ccolor(1,1:2),N,1), linspace(ccolor(1,end),0,N)';
repmat(ccolor(2,1:2),N,1), linspace(0,ccolor(2,end),N)']);
ccolor = hsv2rgb([repmat(ccolor(1,1),N,1), linspace(ccolor(1,end),0,N)', repmat(ccolor(1,3),N,1);
repmat(ccolor(2,1),N,1), linspace(0,ccolor(2,end),N)', repmat(ccolor(2,3),N,1)]);

B) Change ['color', 'k'] in
set(gca, 'Xlim',xlims,'Ylim',ylims, 'color', 'k','XColor','none','YColor','none',...
To ['color', 'w']:
set(gca, 'Xlim',xlims,'Ylim',ylims, 'color', 'w','XColor','none','YColor','none',...

serafeim loukas

Amazing toolbox. thank you.

Can someone explain me that color correspond to what vector like [1 0 1] ?

Oleg Komarov

I am currently working on a bright theme (to address @Julia and other's request) and on allowing fully formed custom colormaps. This requires a bit of rework in the parameter parsing and on colour control.

Oleg Komarov

@Julia: you can set(gca,'Color','white') but be aware that the way the colormap is set, average values will be dark/black, so you will have a central mass of dark lines. To see what I mean, check the default colormap here
To achieve white background you will need to change the colormap such that the two extremes blend in the middle into white.

Julia Ballester

Really useful and easy to manage! I have a question... Is it possible to change the background of the graph to white? I tried it and I can just change the background of the figure. Any advice will help, thanks!

Julia Ballester

Oleg Komarov

@cmo I cannot reproduce the issue. Can you provide an example?

@Anca Mitrea You need to save it with optional arguments for higher resolution. Please, see the matlab docs for print() and/or saveas(). You can also try export_fig

Anca Mitrea

Awesome tool, love it! I have a question... I would like to print the result on an A0 or A1 paper size and if I simply save it as it is, when I zoom it, it gets pixeled. What should I do? Thank you very much!


works great!
when I use "saveas", the resulting PNG has a white background.
How do I print it to file with the black background?


Thanks Oleg!


Silly question: how do I reference a figure that I generated using your code?


Oleg Komarov

You can normalize your matrix. I left this aspect to the user, since she can choose how to re-map the matrix to an arbitrary interval.

Pascal Schulthess

Absolutely fantastic.
But, I'd love a way to also input arbitrary matrices with arbitrary value ranges. Is there a way to do that?





karlo gonzales

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!