473,745 Members | 2,189 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Plot Data Visualiation for 2D arrays

40 New Member
Does anyone know an easy way to visualise 2D arrays ? Any software that reads them in and displays them ?
Feb 6 '07 #1
9 8132
Ganon11
3,652 Recognized Expert Specialist
Do you mean a way to display all the information in a 2D array in a good way, or a way for you personally to see what a 2D array is?
Feb 6 '07 #2
dschulenburg
40 New Member
Do you mean a way to display all the information in a 2D array in a good way, or a way for you personally to see what a 2D array is?
I am looking for a way to display the data. I have a code that spits out 2D arrays and would like to shiw them as plots as they correspond to a data set with two dimensions. I basically need a Y and a X axis and then the value for every coordiante point....
Feb 7 '07 #3
Ganon11
3,652 Recognized Expert Specialist
The standard way to display 2D arrays is with a set of nested for...loops - an example is

Expand|Select|Wrap|Line Numbers
  1. for (int r = 0; r < ROW_SIZE; r++) {
  2.    for (int c = 0; c < COL_SIZE; c++) {
  3.       cout << array[r][c] << " ";
  4.    }
  5.    cout << endl;
  6. }
This will print out each value in one column of the array, separated by one space each. It will then move to a new line and start with the next column. The resulting output would be something like an inverted x, y coordinate, with each r value being a y coordinate and each c value being an x coordinate. You could switch this by outputting array[c][r].

Is this what you meant?
Feb 7 '07 #4
dschulenburg
40 New Member
I can see how you can print out the values in an array that way. What I need is more a software that allows to display them easily. Imagin your array is an image (e.g. a photo) that has values for different colors or intesitys that you want to have a look at. There must be something that reads an array in and displays it as an image...? Does that make sense ?
Feb 7 '07 #5
macklin01
145 New Member
I wrote some open source code to visualize 2D arrays. Have a look at the EasyBMP project, and take a look at the DataPlotter program.

IIRC, I need to update that program, so let me know if you encounter problems. But a pre-compiled version is included.

Also, here's a very simple way to visualize a 2D array in grayscale:
Expand|Select|Wrap|Line Numbers
  1. #include "EasyBMP.h"
  2.  
  3. // ...
  4.  
  5. // suppose you already have an array data[i][j] 
  6. // of size M x N
  7.  
  8. // find the min and max of the array
  9.  
  10. double min = 9e9;
  11. double max = -9e9;
  12. for( int i=0 ; i < M ;i++ )
  13. {
  14.  for( int j=0; j <N ; j++ )
  15.  {
  16.   if( data[i][j] < min )
  17.   { min = data[i][j]; }
  18.   if( data[i][j] > max )
  19.   { max = data[i][j]; }
  20.  }
  21. }
  22.  
  23. BMP Output;
  24. Output.SetSize(M,N);
  25.  
  26. // plot the pixels
  27.  
  28. for( int i=0 ; i < M ; i++ )
  29. {
  30.  for( int j=0; j < N ; j++ )
  31.  {
  32.   double scaled_value = ( data[i][j] - min )/( max-min + 1e-16 );
  33.   ebmpBYTE pixel_value = (ebmpBYTE) ( scaled_value * 255.0 );
  34.   Output(i,j)->Red = pixel_value; 
  35.   Output(i,j)->Green = pixel_value;
  36.   Output(i,j)->Blue = pixel_value;
  37.  }
  38. }
  39.  
  40. // save the file
  41.  
  42. Output.WriteToFile( "image.bmp" );
  43.  
I can show you fancier color functions, other than grayscale later. (I use a homebrew "rainbow" function myself.) In fact, I just rewrote some visualization software for my cancer simulator this afternoon using this type of deal. Here's a typical screenshot. :-) We can also do other fancy things, like resizing, labeling, etc., later. First, just get the data on the screen. ;-)

I hope this helps! -- Paul
Feb 7 '07 #6
macklin01
145 New Member
I didn't get the image uploaded in time. Here's a (highly degraded) version, to fit in the upload size limits. -- Paul
Feb 7 '07 #7
macklin01
145 New Member
Do'h!

Still wasn't fast enough. Darn those stringent limits! :) Here it is for real. ;) -- Paul
Attached Images
File Type: jpg frame00000145.JPG (29.8 KB, 859 views)
Feb 7 '07 #8
dschulenburg
40 New Member
Do'h!

Still wasn't fast enough. Darn those stringent limits! :) Here it is for real. ;) -- Paul
Paul, thanks, I'll have a quick look at your webpage ! Does that only work for C++ or also in C ?
Feb 7 '07 #9
macklin01
145 New Member
Paul, thanks, I'll have a quick look at your webpage ! Does that only work for C++ or also in C ?
No problem, dr. s.

While most of the code uses C, EasyBMP is implemented as a few C++ classes, particularly the BMP class. (The object-oriented nature of C++ makes it much easier to implement the read/write functions, etc.) Thanks -- Paul
Feb 7 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2992
by: Jan Wienhausen | last post by:
Hi, I need to do a plot of data that is beeing acuired. For that the plot needs to be updated after aquiering a new tuple. At the moment I allways do this after a new tuple is aqcuired: plot(ar,br,'ro') show() #ar is arrays were the new tuple is put in position and After that i call sleep(5) until I can acuire the next tuple.
30
4165
by: nephish | last post by:
Hey there, i have tried about every graphing package for python i can get to work on my system. gnuplot, pychart, biggles, gdchart, etc.. (cant get matplot to work) so far, they all are working ok. I need to make an x y chart for some data that comes in from sensors at different times durring the day. i need it to show the value in the y and the time in the x . no problem so far. But what i cannot get to happen is to scale x (time of the...
6
17694
by: googlinggoogler | last post by:
Hiya, I've got a PIC microcontroller reading me humidity data via rs232, this is in ASCII format. I can view this data easily using hyperterminal or pyserial and convert it to its value (relative humidty with ord(input)) But what im trying to do is plot the data in real time, ideally with pylab - as it looks simple to use and simple is the way i want to go! My code is below, it doesnt show a graph, I was wondering whether
0
1384
by: N/A | last post by:
Hi all, Can any1 please guide me how to plot data from Excel by Matplotlib? Let's say, I have 78(rows) x 8(cols) data in an Excel sheet. I would like to plot data for all 78(rows) at 4th column against data for all 78(rows) at 7th column. How to plot it? Thank u!
0
1652
by: toton | last post by:
Hi, for my project I needs a few plots to visualize the data (mostly x-y plot) . Most of the existing plotting library either copy the data and do plotting, or takes a data pointer to an 2d x-y array, and plots it (without copying). As my data set is not so trivial (sometimes it is vector, sometimes list etc), and x, y are not fixed. so I want to have a plot as generic one, which take begin & end iterator, iterate over it and show the...
0
1584
by: jatininfo | last post by:
Hi.. I am working on a medical device which will give the various current reading of various types of parameter from patient body like oxygen lavel, breathing, tampature etc, and it's a ventilator, so we are continousally getting live data from this device in the form of XML Stream. Now i need to plot this live data on a running graph means a moving graph, i am able to plot this on a .Net (C# Window application), But now i have to plot this...
0
1621
by: foton002 | last post by:
i wanna plot a X_Y graph with C# for instance get x and y as 2 arrays and plot them. could u please help me thanks
1
8341
by: dazzler | last post by:
Hi! I just moved using wxpython so I'm a quite newbie. I was wondering how to update plotcanvas? In my code I made button with event to update plotcanvas with new results, but how to properly do it? because now when I press button it makes new "layer" into my GUI and doesn't delete the old plot. Should I first delete the old one and then create new plot, or just update old one, well either way I don't know how to do it... =/ ...
1
5583
by: kjb034 | last post by:
I have the following macro. It works fine, creating an XY scatter plot in Excel 2003, but when one of my users runs it in Excel 2007, it creates a scatter plot with lines. Why does it do this? I am using "ChartType = xlXYScatter", not xlXYScatterLines. Public Sub CreateChart(ByVal viLabeledSeries As Integer, ByVal viNonLabeledSeries As Integer, ByVal vsWorkbookName As String, ByVal vsPopulationName As String, ByVal vsPrimaryAxisTitle...
0
8970
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9486
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9277
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8218
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6763
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6057
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4827
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3286
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.