Example: Polar Chart

A simple Polar chart is constructed in this example. The function r = 0.5 + cos(theta), for 0 = theta = p is plotted. This class extends JFrameChart , which manages the window.
import com.imsl.chart.*;
import java.awt.Color;
import java.applet.Applet;

public class PolarEx1 extends javax.swing.JApplet {
    private JPanelChart panel;
    
    public void init() {
        Chart chart = new Chart(this);
        panel = new JPanelChart(chart);
        getContentPane().add(panel, java.awt.BorderLayout.CENTER);
        setup(chart);
    }
    
    static private void setup(Chart chart) {
        Polar axis = new Polar(chart);
        
        double r[] = new double[20];
        double theta[] = new double[r.length];
        for (int k = 0;  k < r.length;  k++) {
            theta[k] = Math.PI*k/(r.length-1);
            r[k] = 0.5 + Math.cos(theta[k]);
        }
        Data data = new Data(axis, r, theta);
        data.setDataType(Data.DATA_TYPE_MARKER | Data.DATA_TYPE_LINE);
        data.setLineColor(Color.green);
        data.setMarkerColor(Color.blue);
    }
    
 
    public static void main(String argv[]) {
        JFrameChart frame = new JFrameChart();
        PolarEx1.setup(frame.getChart());
        frame.show();
    }
}

Output

eqn_0369

Link to Java source.