View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
wgPlot - Weighted Graph Plot (a better version of gplot)

4.8 | 8 ratings Rate this file 13 Downloads (last 30 days) File Size: 185 KB File ID: #24035 Version: 1.7
image thumbnail

wgPlot - Weighted Graph Plot (a better version of gplot)


Mike Wu (view profile)


07 May 2009 (Updated )

Plot graphs with weighted vertices and weighted edges from a weighted adjacency matrix.

| Watch this File

File Information

Plot graphs just like gplot. But allow user to input an adjacency matrix with weighted edges and/or weighted vertices. The Edge weights are mapped to a colormap. The vertex weights are proportional to the vertex size. Using parameter-value pairs, user can even specify the vertex scaling factor, edge width, and the colormap used to show other meta data associated with the vertices. (Couple of the graph included as example were from David Gleich's matlabBGL package.)


Gplotwl and Matlab Bgl inspired this file.

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
08 Oct 2016 samaneh jolany

I have plotted a graph by wgplot. The color of the vortices must correspond the colorbar but it does not
What to do now?

Comment only
17 Aug 2016 Thales

Thales (view profile)

28 Apr 2015 Xinwei Shen

06 May 2014 mahyar

mahyar (view profile)

Thanks for this very useful tool.

I have two question to modify this program:

1- What should I do see the results of edges normalized between 0 and 1? As in the fig shown in this page it is between 0.24 to 9.97.

2- What should I do map edge weights to edge width (thickness)rather than edge colormap?

11 Dec 2013 Smita

Smita (view profile)

Even after I fixed all the other bugs in wgPlotDemo, the last of the demos uses fruchterman_reingold_force_directed_layout, which was not included in wgPlotDemo. I downloaded that off of the mathBgl package, but that function refers to another function called fruchterman_reingold_mex which was not in that package! So now I'm not sure what to do. Any hints on where to find that function?

Comment only
28 Oct 2013 Kishan

Kishan (view profile)

I cannot run the simple example, I get the following error:

Error using scatter (line 68)
S must be a scalar or a vector the same length as X.

Error in wgPlot (line 153)

Comment only
31 Mar 2013 Charles Nelatury


11 Mar 2013 AlexV Mantzaris

I commented out axesArea to get the network plot into a figure with other subplots and it works exactly as I need it. Work well and fast even for a large number of edges.

27 Mar 2012 Anthony Saccullo

Great program. Contains exactly what I'm looking for. I'm just having issues with the vertices having color. I'd like to have them all be a uniform size, but have the color change with weight. Or have both the color and size change would work too. The issue I'm having is that when the weight values are inputted some of the nodes do not show a weight. Any suggestions?

13 Dec 2010 Maxime

Maxime (view profile)

Very useful, nice display, computationally fast. Good job, thank you!

03 Nov 2009 Reza Farrahi Moghaddam

Please apply the following changes:

1. file: wgPlotDemo.m, line: 2, load('cores_example.mat')
2. file: wgPlotDemo.m, line: 46, load('cs-stanford.mat')
3. file: axesArea.m, line: 25, if ishghandle(varargin{1})
4. file: wgPlot.m, line: 150, hV=scatter(coord(qq,1),coord(qq,2),vWt(qq),vrtxCol(qq),'filled');
5. file: wgPlot.m, line: 153, hV=scatter(coord(qq,1),coord(qq,2),vWt(qq),'filled','MarkerFaceColor',[1,0.5,0.2]);

02 Aug 2009 Jeroen

Jeroen (view profile)

Even for a very simple example, i get an error:

>> wgplot(sprand(10,10,0.2), rand(10,2));

> In wgPlot at 36
In corrcoeff at 44
??? Error using ==> ishghandle
Too many input arguments.

Error in ==> axesArea at 25
if ishghandle(varargin{1},'axes')

Error in ==> wgPlot at 36
axesArea(h,[6 7 5 5]);

What's wrong?

Comment only
18 May 2009 1.3

Added an missing auxiliary file for setting the axes' plot area. And updated the wgPlot to include a parameter for changing the marker style.

18 May 2009 1.4

Added a missing helper file for setting the plot area for plotting the graph. Also updated wgPlot to include parameter-value pairs for specifying the marker style.

19 May 2009 1.5

Fixes a minor but that plots all the vertices even when some of them are not connected to any other vertices. Now it only plots vertices that have connections by default when the adjacency matrix has lot of row/columns with no connections.

05 Jun 2009 1.6

fix bug on plotting colored/sized markers over the default marker when user specify the vertex weight/meta data.

23 Jun 2009 1.7

included a missing helper function prh.m

Contact us