Hi, hmm hav a query right here about how do i go about plotting a map/graph using c programming.

i hav the x and y cordinates which are the variables, but do not know how to go about starting/writing the program.

i heard one of the ways is to import the data using microsoft Excel

Would be grateful if anyone could guide me through this problem..


Recommended Answers

All 9 Replies

Plotting a graph will almost certainly need to use the services of the operating system to be accomplished. In a console you can plot a simple ascii histogram but not much more. What OS are you using?

i'm using Miicrosoft Xp Windows.

About what u said earlier about the simple ascii histogram .. Could u maybe explain what is it about.. Nv heard of it b4..

Its trivial to plot asterixes for instance in the console but if you want curves or anything more graphical you will need to use a window. How much do you know about making a window and painting it in C?

Just started reading up some c programming books not long ago.. Perhaps u could give me an example of how to plot just 1 cordinate or something.. because i'm not quite sure about this array thingy.

would appreciate it :)

The C and C++ languages do not have native graphical capabilities. To do things other than bar graphs oriented either horizonally or vertically with the bar made up of a series of characters, (that is histogram), you need to use a third party library such as Windows API or even more sophisticated OpenGL or DirectX.

Example of horizontal histogram to indicate results of poll indicated 60% for option A and 40% for option B using the asterix char:

A ******
B ****

and vertically

* *
* *
* *
* *

Sorry, but my working environment would be using the LINUX operating system, so i guess the library file which i include would be differenet ?

Perhaps u could show me an example of the program ?

perhaps you should have a go yourself. To do a histogram in ASCII all you need is iostream. You will not get much help by showing no effort and demanding code.

If you are working in the linux environment I reccomend using an API such as Qt (for KDE) and gtk+ (for GNOME).

These APIs will allow you to easily have access to opengl functionality (you can read their docs).

For example, with Qt, you would create a main window and overlay the window with a QCanvas widget. On the QCanvas, you can use a paint method to draw pixels at specific locations.

Definetly check out the appropriate api for your linux desktop environment (I'm assuming you are using either KDE or GNOME) -- it makes using OpenGL alot easier.

Let me know how it goes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.