![]() |
| | #1 |
| Registered User Join Date: Apr 2009
Posts: 1
| How to plot a graph using C |
| Katie_lin is offline | |
| | #2 |
| Registered User Join Date: Apr 2007
Posts: 46
| If you are just wanting to know if it is a straight line or not (as in a yes or no answer), just ask yourself how you would check that with pen and paper, then implement the same check in code. |
| markcole is offline | |
| | #3 |
| Super Moderator Join Date: Sep 2001
Posts: 4,680
| Well you can determine characteristics of the line mathematically. If you still want to visibly display the graph, you should look into a graphics library. SDL might be a good choice. (libsdl.org) Then of course you could use | \ / and -'s to display the line! |
| sean is offline | |
| | #4 |
| Math wizard Join Date: Dec 2006 Location: Minot, ND, USA
Posts: 516
| An alternative is to write a BMP file. When I wanted to see how the landscape of my 2D game was going to be, I had the program write a BMP file, at 72,000x48,000 pixels and using 1-bit color. Then just open the bitmap image in a standard image-editing program. All you need to know is the BMP file's format (I like making the width a multiple of 4 for simplicity reasons (32 for the 1-bit image)), and how to change the pixel colors accordingly. 24-bit is the easiest to work with.
__________________ High elevation is the best elevation. The higher, the better the view! My computer: XP Pro SP3, 3.17 GHz C2D CPU, 4 GB DDRII800 RAM (3 GB effective), X-Fi Platinum sound, GeForce 7600 GT, 1920x1440 resolution, 250 GB HDD, Visual C++ 2008 Express |
| ulillillia is offline | |
| | #5 |
| +++ OK NO CARRIER Join Date: Oct 2001
Posts: 10,262
| If you're writing your own (not using a library) method of outputting BMP files, I'd suggest going with TGA instead. They're much simpler to figure out. If you're looking for more file types: Wotsit.org Quzah.
__________________ Hundreds of thousands of dipshits can't be wrong. Are you up for the suck? |
| quzah is offline | |
| | #6 |
| Registered User Join Date: Nov 2005
Posts: 146
| And if you just want to visualize the data aquired by a C program, dump values in a file, and use gnuplot to do the plotting. You can even write a script file doing the plotting using C, and launch gnuplot with simple system("") call. (or fork and exec). re-inventing the wheel can be cool and teach you a lot, but if the point is to get results... |
| Maz is offline | |
![]() |
| Tags |
| graph, linux |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| error help making no sense | tunerfreak | C++ Programming | 5 | 04-17-2007 07:55 PM |
| problem with plot a linear graph on the command line | dionys | C Programming | 5 | 04-17-2004 07:01 AM |
| plot a graph on the screen | dionys | C Programming | 4 | 04-15-2004 02:46 PM |
| get the data and plot the graph | lwong | Windows Programming | 3 | 01-01-2004 09:00 AM |
| Minimize crossing edges in undirected graph | Shiro | C Programming | 0 | 12-26-2001 04:48 AM |