473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

plot

I've not used graphics.h before. How can I plot a function say
y=sin(x) ?

Aug 28 '07 #1
7 2575
In article <11**********************@x35g2000prf.googlegroups .com>,
Umesh <fr****************@gmail.comwrote:
>I've not used graphics.h before. How can I plot a function say
y=sin(x) ?
Sorry, graphics.h is not part of the C programming language.

There are a number of completely different graphics.h around.
You need to consult a reference suitable for your implementation.
Poking around a moment, I see an old example that might still
be of value for you. Or maybe not, considering all the different
graphics.h around.

http://www.mycplus.com/Programming-N....asp?NewsID=33

--
Prototypes are supertypes of their clones. -- maplesoft
Aug 28 '07 #2

"Umesh" <fr****************@gmail.comwrote in message
news:11**********************@x35g2000prf.googlegr oups.com...
I've not used graphics.h before. How can I plot a function say
y=sin(x) ?
It's a platform-specific header.

I've no idea how it works, but presumably you will need to intialise a
graphics display. Then there will almost certainly be a function called
something like plotxy(). It may take floats but will probably take integers.

Your x axis will go from -PI to + PI, whilst your y axis will go from -1 to
+1. However to really see the shape of the function, keep the scales the
same, that's why we measure angles in radians.

So all you need to do is maintain a double x, and take pixel steps from -PI
to +PI. Call sin() to get y. Then convert from the mathematical coordinates
to the pixel coordinates, making x = 0, y = 0 the centre pixel of the
display, and call the plot function.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm
Aug 28 '07 #3
Walter Roberson wrote:
In article <11**********************@x35g2000prf.googlegroups .com>,
Umesh <fr****************@gmail.comwrote:
>I've not used graphics.h before. How can I plot a function say
y=sin(x) ?

Sorry, graphics.h is not part of the C programming language.

There are a number of completely different graphics.h around.
You need to consult a reference suitable for your implementation.
Poking around a moment, I see an old example that might still
be of value for you. Or maybe not, considering all the different
graphics.h around.

http://www.mycplus.com/Programming-N....asp?NewsID=33
I'm sure you are trying to be helpful but any random graphics.h header
is likely to be utterly useless. A given header might have a function
prototype. The actual function must be in a library linked as we build
the executable. The header and the library are married.

If your implementation doesn't have a conio.h header for example,
copying one from Borland or other system may not give you getch() or
clrscr() or whatever. The functions are in the library, not the header.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Aug 28 '07 #4
In article <It******************************@comcast.com>,
Joe Wright <jo********@comcast.netwrote:
>Walter Roberson wrote:
>In article <11**********************@x35g2000prf.googlegroups .com>,
Umesh <fr****************@gmail.comwrote:
>>I've not used graphics.h before. How can I plot a function say
y=sin(x) ?
>Poking around a moment, I see an old example that might still
be of value for you. Or maybe not, considering all the different
graphics.h around.
>http://www.mycplus.com/Programming-N....asp?NewsID=33
>I'm sure you are trying to be helpful but any random graphics.h header
is likely to be utterly useless. A given header might have a function
prototype. The actual function must be in a library linked as we build
the executable. The header and the library are married.
I did not suggest that Umesh copy a graphics.h file from somewhere.

The article referenced shows an actual example of graphics
functions in use in Windows, -likely- based upon the old Borland
graphics library. The Borland graphics library is the one that
came up most often for graphics.h and several more modern implementation
libraries I found in my poking appear to deliberately retain
compatability with the Borland facilities. And we've encountered
Umesh often enough to know he is using Windows of some kind.

Notice that my wording was that it was "an old example", rather
than any kind of wording suggesting that I was pointing to a
copy of graphics.h or pointing to an implementation library.
"example" -- something to be examined and studied for learning
purposes.
--
Programming is what happens while you're busy making other plans.
Aug 28 '07 #5
On Aug 28, 1:20 pm, Umesh <fraternitydispo...@gmail.comwrote:
I've not used graphics.h before. How can I plot a function say
y=sin(x) ?
In the C language (all by itself) you can plot a character based
graph.

If you want to make pretty pictures, you will need to use a graphical
extension to the language.

PHIGS is one standards based extension.
XWindows is another.
GKS is another.
CGM is another.

Or you can use something like OpenGL or DirectX, which are proprietary
but well accepted.

Aug 28 '07 #6
On Aug 28, 1:20 pm, Umesh <fraternitydispo...@gmail.comwrote:
I've not used graphics.h before. How can I plot a function say
y=sin(x) ?
If you are interested in drawing pictures, you might try
news:comp.graphics.algorithms.
Of course, you will read their FAQ before posting.

Aug 29 '07 #7
Malcolm McLean wrote:
>
"Umesh" <fr****************@gmail.comwrote in message
news:11**********************@x35g2000prf.googlegr oups.com...
I've not used graphics.h before. How can I plot a function say
y=sin(x) ?
It's a platform-specific header.

I've no idea how it works, but presumably you will need to intialise a
graphics display. Then there will almost certainly be a function called
something like plotxy(). It may take floats but will probably take integers.
[...]

Not necessarily, although that's probably what the OP wants.

Way (way, way!) back, I would plot things like that by placing
the X axis down the page, and draw the X axis with "|" and place
a "*" along the Y axis, using spaces to place the characters as
needed.

--------*--------
| *
| *
| *
| *
| *
| *
*
* |
* |
* |
* |
* |
* |
*

Pure text, and easily done in pure ANSI C. (Although it does
depend on a monospaced output device.)

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Aug 29 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dr. Colombes | last post by:
MatPlotLib question: How to get more different size plot symbols in the plot function ? Is there a way to get different size squares (or circles or triangles, etc.) ? For example, in a two...
1
by: Dr. Colombes | last post by:
Using MatPlotLib plot function, is there a way to get variable size plot symbols? For example, using symbol strings like 'o' (circle), 's' (square), 'x' (cross), etc., is there a way to specify...
1
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: ...
30
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...
8
by: questions? | last post by:
I want to make a 3d plot. x is a vector(discrete), y is also a vector(discrete), for each pairwise x,y I have a value z(x,y)(it is not a function, just discrete values for each pair of x,y) I...
0
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...
6
by: redcic | last post by:
Hi all, I've just downloaded scipy v 0.5.2 and I would like to be able to draw plots. I've tried: import scipy.gplt import scipy.plt import scipy.xplt and none of them work. Are these...
0
by: meggahertz | last post by:
I am using matplotlib to generate plot in python in linux. The porblem I am facing is that when I generate a plot using plot() then show() the script stops at that point until I close the plot...
1
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...
1
by: oyinbo55 | last post by:
I am trying to use the pylab plot command on my laptop running Ubuntu 6.06 (Dapper). Although the plot command works fine on my XP desktop at work, I cannot open the plot window on the laptop. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.