paxos1977 paxos1977 - 9 months ago 63
C++ Question

Scatter Plots in C++

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?

Answer Source

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.