Plotting in C++?

R

rufus

In matlab it very easy to plot a function:

x = [1:10]
y = x.*20
plot(x,y)

A little windows pops up with the graph and some editing options. Is there
anything like this for C++, or do I have to write a rasterizer from scratch?
 
E

Erik Wikström

In matlab it very easy to plot a function:

x = [1:10]
y = x.*20
plot(x,y)

A little windows pops up with the graph and some editing options. Is there
anything like this for C++, or do I have to write a rasterizer from scratch?

There are libraries available you can use if you do not want to write
your own, perhaps you can even uses Matlab in some way.
 
R

rufus

Erik Wikström said:
In matlab it very easy to plot a function:

x = [1:10]
y = x.*20
plot(x,y)

A little windows pops up with the graph and some editing options. Is
there
anything like this for C++, or do I have to write a rasterizer from
scratch?

There are libraries available you can use if you do not want to write
your own,

Which?

perhaps you can even uses Matlab in some way.


I would like to avoid any dependency on matlab
 
J

Jerry Coffin

In matlab it very easy to plot a function:

x = [1:10]
y = x.*20
plot(x,y)

A little windows pops up with the graph and some editing options. Is there
anything like this for C++, or do I have to write a rasterizer from scratch?

C++ doesn't specify such a library as part of the standard. Depending on
what you're trying to accomplish, you can use native plotting
capabilities under most systems (e.g. SetPixelV under Windows) or you
can use a semi-portable library for a pretty fair number of systems
(e.g. Qt, wxWidgets). Most of these more or less require a fair amount
of nonstandard code though...
 
S

Stefan Ram

Jerry Coffin said:
C++ doesn't specify such a library as part of the standard.

One can always plot in two colors as follows using only the
standard library. (Even without the large gaps visible here)


*
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |

One could use a very small font to increase display
resolution. If one has terminal with corresponding control
codes, one also can output them to get more than two different
colors.

Here is another example: The output of a program that writes
and rotates a letter using subpixels for anti-aliasing. So,
many techniques of computer graphics can be studied with the
standard library only.


****
**********
**************
*****************
***** ************
***** ************
**** ************
**** ************
***** ************
***** ***************
**** **** ************
**** **** ********
***** **** ***
***** *****
**** ****
**** ****
*********
*******
*****
****
*****
*****
****
****
*****
*****
**
 
E

Erik Wikström

One can always plot in two colors as follows using only the
standard library. (Even without the large gaps visible here)

Or you can write to a file and use an external plotter, such as gnuplot.
 
S

Stefan Ram

=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?= said:
Or you can write to a file and use an external plotter, such as gnuplot.

Or one can create files for similar programs, such as dot (of
the package »graphviz«), or one can write a file of a graphic
format such as SVG, png or so.
 
A

anon

rufus said:
Erik Wikström said:
In matlab it very easy to plot a function:

x = [1:10]
y = x.*20
plot(x,y)

A little windows pops up with the graph and some editing options. Is
there
anything like this for C++, or do I have to write a rasterizer from
scratch?
There are libraries available you can use if you do not want to write
your own,

Which?


Would OpenGL do what you want?
 
A

asm23

rufus said:
In matlab it very easy to plot a function:

x = [1:10]
y = x.*20
plot(x,y)

A little windows pops up with the graph and some editing options. Is there
anything like this for C++, or do I have to write a rasterizer from scratch?
I personally suggest you could use "dislin", it is a package that fit
your need. It can used in C++ to plot graphs. see
http://www.mps.mpg.de/dislin/
 

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
474,173
Messages
2,570,938
Members
47,475
Latest member
NovellaSce

Latest Threads

Top