Scatter Plots in C++ [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
What is the best way to graph scatter plots in C++?
Do you write data to a file and use another tool? Is there a library like matplotlib in Python?

I always write out data and then using gnuplot to create my graphs. It is by far the best way I have found of producing graphs in a variety of formats: eps, png, jpeg, xpm, you name it.
gnuplot will do scatter plot very easily. Provided the x and y values are in 2 space-separated columnss, then
plot "data.txt" using 1:2
Will give you a quick scatter plot. Then you can adjust it and what not using other gnuplot commands.
If you are involved in sciences, then learning gnuplot will be very valuable to you. It kicks the crap out of doing excel plots for sure and it eases the task of making plots to include in papers.

If you are looking for a C++ library rather than I independent plotting tool like gnuplot, I would consider the following:
Koolplot
dislin (Wikipedia article on dislin)
dislin seems to be the more interesting of the two. Here is a description extracted from the wikipedia article:
DISLIN is a high-level and easy to use plotting library developed by Helmut Michels at the Max Planck Institute in Katlenburg-Lindau, Germany. Helmut Michels currently works as a mathematician and Unix system manager at the computer center of the institute.
The DISLIN library contains routines and functions for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Several output formats are supported such as X11, VGA, PostScript, PDF, CGM, HPGL, SVG, PNG, BMP, PPM, GIF and TIFF.
DISLIN is available for the programming languages Fortran 77, Fortran 90/95 and C. Plotting extensions for the languages Perl, Python and Java are also supported for most operating systems. The current version of DISLIN is 9.4, released in October 2008. The first version 1.0 was released in December 1986.
The DISLIN software is free for non-commercial use.

Very heavy solution: you could link against ROOT, which will do just about anything you want:
runs on Mac, Windows and Linux
runs compiled or using the cint interperter
output to a file in encapsulated postscript, PDF, gif, png...
display to the screen using several different technologies
serialize the data in an internal format that can be manipulated later
Sure, its a bit much for most people, but it does do exactly what you asked for. I use it because I know it and it is already on my machines becase I'm that kind of physicist.

Good old GNU, they have everything...
http://directory.fsf.org/project/plotutils/

This is certainly not the best way but I usually write output files that can be read by R and use this, along with an appropriate script, to plot the graphs.

The problem here is that C++, unlike Java for example, does not have built-in GUI or graphics. If you want to generate graphs with C++ you would need to use a GUI library available for your OS. There are free GUI libraries, many cross-plaform such as Qt or GTK.
However, as other people have pointed out, the easiest thing for you to do would be to save the data into a text file, and use another program to generate the graph. gnuplot is definitely a good choice. It comes standard with most linux distros, and you get for Windows under cygwin.

Regards plotting in C++ for anyone who didn't do it yet. I will say what I did to plot Graphs in C++
Download the zipped file "gp443win32.zip" from http://sourceforge.jp/projects/sfnet_gnuplot/downloads/gnuplot/4.4.3/gp443win32.zip/
Extract it in "C:\Gnuplot"
then I read "C:\Gnuplot\gnuplot\README.Windows"
and I got these information:
I used Windows 7 ==> so you need to download "winhlp32.exe"... just search for it "winhlp32.exe Windows 7" in a search engine and go through the first link.
Append to the "Path" Environment variable the path for binary folder which is "C:\Gnuplot\gnuplot\binary"
then I shutdown my computer and open it again. After I found that it didn't sense the change in the environment variables :D
you need now to write a sample code to test your plotting ability :)
so you can visit this link
http://code.google.com/p/gnuplot-cpp/source/browse/#svn%2Ftrunk
to see the header file "gnuplot_i.hpp" and source file "example.cc".
You will get many and many graphs, choose your appropriate graph, customize your core, and enjoy :)

If you're familiar with matplotlib, you can embed python in C/C++ applications. Depending on what you want it for, this might be a quick solution.

Chart Director has bindings for C++. I've used their .Net libraries, and I've been pretty happy with them. It's a pretty cheap library, and gives you the power to do all sorts of different charts.

Related

Extracting page dimensions from a PDF with a C++ program [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I want to be able to generate PDF output from my (native) C++ Windows application. Are there any free/open source libraries available to do this?
I looked at the answers to this question, but they mostly relate to .Net.
LibHaru
Haru is a free, cross platform,
open-sourced software library for
generating PDF written in ANSI-C. It
can work as both a static-library (.a,
.lib) and a shared-library (.so,
.dll).
Didn't try it myself, but maybe it can help you
I worked on a project that required a pdf report. After searching for online I found the PoDoFo library. Seemed very robust. I did not need all the features, so I created a wrapper to abstract away some of the complexity. Wasn't too difficult. You can find the library here:
http://podofo.sourceforge.net/
Enjoy!
If you're brave and willing to roll your own, you could start with a PostScript library and augment it to deal with PDF, taking advantage of Adobe's free online PDF reference.
jagpdf seems to be one of them. It is written in C++ but provides a C API.
It depends a bit on your needs. Some toolkits are better at drawing, others are better for writing text. Cairo has a pretty good for drawing (it support a wide range of screen and file types, including pdf), but it may not be ideal for good typography.
PDF Hummus.
see for http://pdfhummus.com/ - contains all required features for manipulation with PDF files except rendering.
LibHaru seems to be used by many.
A non-open source approach is: PDF Creator Pilot which provides more language options including C++, C#, Delphi, ASP, ASP.NET, VB, VB.NET, VBScript, PHP and Python
muPdf library looks very promising: http://mupdf.com/
There is also an open source viewer: http://blog.kowalczyk.info/software/sumatrapdf/free-pdf-reader.html
Try wkhtmltopdf
Software features
Cross platform.
Open source.
Convert any web pages into PDF documents using webkit.
You can add headers and footers.
TOC generation.
Batch mode conversions.
Can run on Linux server with an XServer (the X11 client libs must be installed).
Can be directly used by PHP or Python via bindings to libwkhtmltox.
http://wxcode.sourceforge.net/docs/wxpdfdoc/
Works with the wxWidgets library.

c++ application using qt, how to include gnuplot

Im looking for a solution or some guidelines on how to, from a c++ application using Qt, create scientific plots. I have set my mind on gnuplot because it have nice features for later use of my plots in latex and such.
My question is then, can i and how do i accomplish to show a plot in qt and also makes it possible to expose the gnuplot commands for generating the plot later for reporting.
Should i based on my data create some datafile, and create a text file with the commands?
Can it be integrated into my c++ application such that i create the plot, see it in my application and then save the data and plot file.
Any input would be nice. I dont now gnuplot at the moment, and wonder if its a application on unix or its a library i can use in my application. Thanks.
Easiest way is to have your app run gnuplot in a system() or similar call, plotting to an image and then display the image.
If you want more detailed control there is an iostream lib to talk to gnuplot or an old C interface
If your not set on gnuplot look into:
KD Chart, it uses Qt ModelView programming model. It's cross platform and even has a plugin that appears as a widget in Qt Designer.
The R-Project is great for plotting might be all you need as a standalone program, but also as a Qt interface R-Forge. It too is cross platform.
Note:
I havn't tried R-Forge yet. R is actually a statistical programming language.
KD Chart targets business type charts but may have what you need.

Open source PDF library for C/C++ application? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I want to be able to generate PDF output from my (native) C++ Windows application. Are there any free/open source libraries available to do this?
I looked at the answers to this question, but they mostly relate to .Net.
LibHaru
Haru is a free, cross platform,
open-sourced software library for
generating PDF written in ANSI-C. It
can work as both a static-library (.a,
.lib) and a shared-library (.so,
.dll).
Didn't try it myself, but maybe it can help you
I worked on a project that required a pdf report. After searching for online I found the PoDoFo library. Seemed very robust. I did not need all the features, so I created a wrapper to abstract away some of the complexity. Wasn't too difficult. You can find the library here:
http://podofo.sourceforge.net/
Enjoy!
If you're brave and willing to roll your own, you could start with a PostScript library and augment it to deal with PDF, taking advantage of Adobe's free online PDF reference.
jagpdf seems to be one of them. It is written in C++ but provides a C API.
It depends a bit on your needs. Some toolkits are better at drawing, others are better for writing text. Cairo has a pretty good for drawing (it support a wide range of screen and file types, including pdf), but it may not be ideal for good typography.
PDF Hummus.
see for http://pdfhummus.com/ - contains all required features for manipulation with PDF files except rendering.
LibHaru seems to be used by many.
A non-open source approach is: PDF Creator Pilot which provides more language options including C++, C#, Delphi, ASP, ASP.NET, VB, VB.NET, VBScript, PHP and Python
muPdf library looks very promising: http://mupdf.com/
There is also an open source viewer: http://blog.kowalczyk.info/software/sumatrapdf/free-pdf-reader.html
Try wkhtmltopdf
Software features
Cross platform.
Open source.
Convert any web pages into PDF documents using webkit.
You can add headers and footers.
TOC generation.
Batch mode conversions.
Can run on Linux server with an XServer (the X11 client libs must be installed).
Can be directly used by PHP or Python via bindings to libwkhtmltox.
http://wxcode.sourceforge.net/docs/wxpdfdoc/
Works with the wxWidgets library.

GUI system development resources? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Could someone recommend any good resources for creating Graphics User Interfaces, preferably in C/C++?
Currently my biggest influence is 3DBuzz.com's C++/OpenGL VTMs (Video Training Modules). While they are very good, they cover a large area of graphics programming, so only skim the surface of GUI programming.
This question does relate to "How do I make a GUI?", where there is also a rough outline of my current structure.
Any response would be appreciated.
Edit:
I've just read some of the answers and spotted that I've missed some points. I had to type the question twice as I caught the wrong button and lost it.
I missed two important points, first: This will be used cross platform including homebrew on a Sony PSP. Second: I want to create a GUI system not use an existing one.
Edit 2: I think some of you are missing the point, I don't what to use an existing GUI system I want to build one.
Qt in it's current form is not portable to the PSP, never mind the overkill of such a task.
That said I've decided to create an IM-GUI, and have started to prototype the code.
I wouldn't use OpenGL for the GUI unless you are planning for hardware accelerated and/or 3D effects that you don't think you would get with a more traditional GUI toolkit (e.g Qt, wxWidgets, GTK, etc). If you just need a quick simple GUI for hosting your OpenGL graphics then FLTK is a nice choice. Otherwise, for rendering the GUI directly in OpenGL their are libraries like Crazy Eddie's GUI that do just that and provide lots of skinnable widgets that you won't have to reinvent. The window and OpenGL context could then be provide with a portable library like SDL.
EDIT: Now that I've gone back and taken at look your other post I think I have a better understanding of what you are asking. For a GUI on an embedded system like the Nintendo DS, I would consider using an "immediate mode" GUI. Jari Komppa has a good tutorial about them, but you could use a more object-oriented approach with C++ than the C code he presents.
http://www.fox-toolkit.org has an API reference, if you're looking how to work with a specific framework. Or were you more interested in general theory or something more along the lines of how to do the low-level stuff yourself?
For more information about "immediate mode" GUI, I can recommend the Molly Rocket forums. There's a good video presentation of the thinking behind IM-GUI, along with lots of discussion.
I recently hacked together a very quick IM-GUI system based on presentation on Jari's page, and in my case, where I really just wanted to be able to get a couple of buttons and boxes on the screen, and more or less just hard code the response to the inputs, it really felt like the right thing to do, instead of going for a more full blown GUI-architecture. (This was in a DirectX-application, so the number of choices I had was pretty limited).
One of the fastest ways is to use python with a gui binding like pyQt, PyFLTK, tkinter, wxPython or even via pygame which uses SDL.
Its easy fast and platform independent.
Also the management of the packages is unbeatable.
See:
http://wiki.python.org/moin/PyQt
http://www.fltk.org/
(tkinter is default and already packaged with python)
http://wxpython.org/
http://www.pygame.org/news.html
For a platform like the PSP, I'd worry slightly about the performance of an IM GUI solution. With a traditional retained mode type of solution, when you create a control, you can also create the vertex buffer/display list or what-have-you required to render it. With an immediate mode solution, it seems to me that you'd need to recreate this dynamically each frame.
You might not care about this, if you're only doing a few buttons, or it's not going to be used in-game (assuming you're making a game) but, especially if you have a fair bit of text, the cost of rendering might start to hurt if you can't find a way to cache the display lists somehow.
Have a look at Qt. It is an open source library for making GUI's. Unlike Swing in Java, it assumes a lot of stuff, so it is really easy to make functional GUI's. For example, a textarea assumes that you want a context menu when you right click it with copy, paste, select all, etc. The documentation is also very good.
I'll second Qt. It's cross platform, and I found it much easier to work with than the built in Visual Studio GUI stuff. It's dual-licensed, so if you don't want your code to be GPL you could purchase a license instead.
I've had a look at the Video from Molley Rocket and Looked through Jari Komppa's cached tutorials.
An IM-GUI seems the best way to go, I think it will be a lot more streamlined, and lot quicker to build than the system I originally had in mind.
Now a new issue, I can only except one Answer. :(
Thanks again to Monjardin and dooz, cheers.
thing2k
I'd have a look at GLAM and GLGooey

C/C++ source code visualization? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Basically I want tools which generate source code visualization like:
function call graph
dependency graph
...
Doxygen is really excellent for this, although you will need to install GraphViz to get the the graphs to draw.
Once you've got everything installed, it's really rather simple to draw the graphs. Make sure you set EXTRACT_ALL and CALL_GRAPH to true and you should be good to go.
The full documentation on this function for doxygen is here.
I strongly recommend BOUML. It's a free UML modelling application, which:
is extremely fast (fastest UML tool ever created, check out benchmarks),
has rock solid C++ import support,
has great SVG export support, which is important, because viewing large graphs in vector format, which scales fast in e.g. Firefox, is very convenient (you can quickly switch between "birds eye" view and class detail view),
is full featured, impressively intensively developed (look at development history, it's hard to believe that so fast progress is possible).
So: import your code into BOUML and view it there, or export to SVG and view it in Firefox.
For the free version:
source is on Github as DoUML
Installers can be downloaded from http://www.bouml.fr/download.html
You can look at different tools for software design and modelling (Rational Rose, Sparx Enterprise Architect, Umbrello, etc). Majority of them have some functionality to reverse modeling by source code, and getting UML class diagrams, and sometimes even sequence diagrams (and this is very close to functions call graph).
But after you get some pictures on really big project code base you could realise that such graphs are rather hard to read and understand. Unfortunally visualization capabilities of complexity are very limited.
As for me, using a "divide and rule" idiom is more convinient approach. You can extract different functionality blocks or layers from your some code base (just sorting cpp-files by different folders sometimes enough). Another way is to use some scripts (bash, python) to create simple csv tables with interested parameters of files, classes or functions like "number of dependencies" etc).
If you use Visual Studio, the 2010 Ultimate release lets you generate sequence diagrams and dependency graphs. However, the release currently supports only .NET application projects.
The team has gotten lots of interest in supporting C++ in a future release, so you might want stay tuned. In the meantime, you can post in the VS 2010 Architectural Discovery & Modeling Tools forum at http://social.msdn.microsoft.com/Forums/en-US/vsarch/threads to request an update. I know the product team loves hearing customer feedback about the tools.
In the meantime, you can learn more about creating sequence diagrams and dependency diagrams from .NET code in the following topics:
How to: Find Code Using Architecture Explorer: http://msdn.microsoft.com/en-us/library/dd409431%28VS.100%29.aspx
How to: Generate Graph Documents from Code: http://msdn.microsoft.com/en-us/library/dd409453%28VS.100%29.aspx#SeeSpecificSource
How to: Explore Code with Sequence Diagrams: http://msdn.microsoft.com/en-us/library/ee317485%28VS.100%29.aspx
To try the RC release and provide feedback, download it at http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=457bab91-5eb2-4b36-b0f4-d6f34683c62a
Try doxygen
Example output from Xerces
In addition to written tools above, you may try understand. But, it is not free.
Might be a duplication, but check out ollydbg, IDA Pro and this website has a whole bunch of resources with some very sexy images.