Have data to fill a triangular matrix, but how do I graph it???? - Please help

N

Nevets Steprock

I'm writing a web program where one of the sections is supposed to output a
correlation matrix. The typical correlation matrix looks like this:

..23
..34 .54
..76 .44 .28
..02 .77 .80 .99

I've written code to calculate the correlation data and it is populated in a
vector like this:

corrcoeff(.23, .34, .54, .76, .44, .28, .02, .77, .80, .99)

I would like to present the data in a triangular matrix where each box has
both the actual number and a colour scheme that represents the strength of
correlation.

I would be open to paying a fee for the help (please note that I'm not a
corporation with deep pockets). I've done exhausting searches on google for
"triangular matrix", code, .net, visual basic, etc... and can't find out how
other programmers are doing it.

Thanks for ANY help you can give.
Steven
 
F

Frank Hileman

Have you seen this?
http://www.inductive.com/help-doc-correl.htm

It looks simple. To draw a rectangular grid row you draw a filled rectangle,
increment by the x width, draw another, until you reach the end of one row.
Then you increment by the y height, and continue to draw rows. FillRectangle
is the method you need on Graphics. The color could be determined by
converting your floats into a scaled integer and indexing into an array of
colors (int)(value * 10).

To draw the text, you can use Graphics DrawString.

Regards,
Frank Hileman

check out VG.net: http://www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
 
B

Bruce Barker

look at htm tables. you should read a book on html (the bookstore is full of
them)

-- bruce (sqlwork.com)
 
K

Kevin Spencer

I don't see a triangular matrix. What I see is a 4X4 table, with 3 empty
cells in the first row, 2 empty cells in the second row, and 1 empty cell in
the third row. At least that's what I see in (imaginary) HTML.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
P

Patrice

And the problem is ? Looks like to me that a table tag should easily allow
this layout ?

Patrice
 
N

Nevets Steprock

Thanks for the info, Frank

The pdf has got me thinking of doing the extra step of sorting the matrix by
similar variables. I was surprised by the difference it makes to the chart.
 
N

Nevets Steprock

I suspect both Bruce and Kevin are suggesting the same. I've only started
programming for the web as of 3 months ago (~20 years of standalone
applications - nothing serious, just mucking around) and have been having a
great time with the new environment.

Since my correlation matrix will be anywhere from 2 to 16 variables, can I
use jscript to do it dynamically or would you suggest I prebuild the table
structure for 16 variables and then resize the rows as necessary?

Steven

PS Thanks for responding.
 
P

Patrice

I would just output server side as many rows as needed. I was not talking
about a table (or array) structure. I was talking about the table HTML tag.

You could render this tag using either a vector or an array. Because of the
structure of this triangular matrix, it should be easy to find out how many
columns you need in the table. You'll then render each row picking an
additional cell each time (1, 2, 3 etc...) and filling the rest of the row
with empty cells...

It would be trivial using an rray, it should be still easy using a vector...

Patrice


--
 
K

Kevin Spencer

Hi Steven,

You're storing the data in an array, and I presume that you have a method
for extracting the various "levels" from the array. So, in the process of
extracting the levels, and I can only guess from what I've seen, the last
row contains the number of elements as the number of columns in the table.
The number of "levels" derived from the array would give you the number of
rows in the table. Once you know that, you can dynamically build an
HtmlTable Control with the number of rows and columns, and add the data into
the table as you build it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
N

Nevets Steprock

Patrice,

I modified my triangular matrix into a NxN matrix by putting some dummy
values in the cells I don't want to waste time calculating. I suppose I'm
being needlessly fussy, but 20 years ago the extra calculations meant a lot
of waiting around and I have never shaken the habit of minimizing what the
processor has to do. Still, it's a lot easier to use in this form.

[update!!] You're right, I can get a quick and dirty correlation matrix up
in no time. Hopefully, it's smooth riding from here.

Steven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top