Scatter Plot on Xcode Mac OS X

Hello,

I am trying to plot scatter for some sequences generated in C++.
I am using xcode on mac os x to generate those sequences.
As i am relatively new to c++ programming can somebody please guide me regarding how can plot a scatter in xcode on Mac OS X 10.9.2 using c++?
Any advice will be highly appreciated.
Thanks a lot.
Doing a quick Google search I found this.
http://stackoverflow.com/questions/215110/scatter-plots-in-c

I would say using a pre- built tool to do it would be the simplest solution.

hell you could even write your file to a csv and use excel to do it.
http://office.microsoft.com/en-us/excel-help/creating-xy-scatter-and-line-charts-HA001054840.aspx
Found this...
This looks really easy to do.
look at the plotting examples
https://www.softintegration.com/docs/ch/chide/

here is some sample code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**********************************************************************
* File: vibration.cpp 
* Display the positions of damped free vibrations of
* overdamped, critical damped, underdamped systems.
* Note: The details about this damped free vibration can be found in
* an exercise in Chapter 6 Functions in the book 
* "C for Engineers and Scientists: An Interpretive Approach"
* by Harry H. Cheng, published by McGraw-Hill, 2009,
* ISBN: 0073376051, ISBN-13: 978-0073376059.
**********************************************************************/
#include <stdio.h>
#include <math.h>
#include <chplot.h>

/* The initial position of the vibration is 4.
   The initial velocity of the vibration is 0 */
double overdamped(double t) {
    return 4.12*exp(-1.57*t) - 0.12*exp(-54.2*t);
}

double criticaldamped(double t) {
    return 4*(1+6*t)*exp(-6*t);
}

double underdamped(double t) {
    return 4.06*exp(-0.5*t)*sin(3*t+1.4);
}

int main() {
    double t0, tf;
    int num = 100;       // number of points for plotting
    CPlot plot;
   
    t0 = 0;
    tf = 10;
    plot.title("Damped Free Vibration");
    plot.label(PLOT_AXIS_X, "time (second)");
    plot.label(PLOT_AXIS_Y, "x");
    plot.func2D(t0, tf, num, overdamped);
    plot.legend("overdamped", 0);
    plot.func2D(t0, tf, num, criticaldamped);
    plot.legend("critically damped", 1);
    plot.func2D(t0, tf, num, underdamped);
    plot.legend("underdamped", 2);
    plot.plotting();
    return 0;
}
Last edited on
I have used Qwt quite a bit: http://qwt.sourceforge.net/index.html
There is a link on that page to a screenshot of a scatter plot. The example code is included in the source.

Qwt forum: http://www.qtcentre.org/forums/23-Qwt
The developer (Uwe) is very active

You will have to download the Qt SDK and then compile compile Qwt yourself though.
Last edited on
Topic archived. No new replies allowed.