4

JFreeChart現在、2D グラフで 3D データを表現するために使用しようとしています。

基本的に、私は と呼ばれる 2 次元配列を持っていdata[i][j]ます。iとは、プロットしたい座標をj表します。の値は、グラフで色として表現したい周波数値を表します。yxdata[i][j]

このようなものが何と呼ばれているのか完全にはわかりませんが、次のようになります。

ここに画像の説明を入力

を使用してこれを実行しようとしていますがXYBlockRenderer、データセットの定義に問題があります。を使用しようとしDefaultXYZDatasetていますが、ここでデータを定義する方法さえ本当に混乱しています。

DefaultXYZDatasetそのようなタスクを達成するために を使用する方法を誰かが説明できますか?

DefaultXYZDataset dataset = new DefaultXYZDataset();

Concentration.dataoutHeight = Concentration.dataout[0].length;

System.out.println(Concentration.dataoutHeight);
System.out.println(ImageProcessor.MAXCBVINT);
double[][] data = new double[3][ImageProcessor.MAXCBVINT];


for (int i = 0; i < Concentration.dataoutHeight; i++) {
    for (int j = 0; j < ImageProcessor.MAXCBVINT; j++) {
        data[0][j] = j;//x value
        data[1][j] = i;//y value
        data[2][j] = Concentration.dataout[j][i][0];//Colour
    }
    dataset.addSeries(i, data);

}
NumberAxis xAxis = new NumberAxis("Intensity");
xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
xAxis.setLowerMargin(0.0);
xAxis.setUpperMargin(0.0);
NumberAxis yAxis = new NumberAxis("Distance to Closest Blood Vessel (um)");
yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
yAxis.setLowerMargin(0.0);
yAxis.setUpperMargin(0.0);
XYBlockRenderer renderer = new XYBlockRenderer();
PaintScale scale = new GrayPaintScale(0, 10000.0);
renderer.setPaintScale(scale);
renderer.setBlockHeight(1);
renderer.setBlockWidth(1);
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinePaint(Color.white);
JFreeChart chart = new JFreeChart("Surface Plot", plot);
chart.removeLegend();
chart.setBackgroundPaint(Color.white);

ChartFrame frame = new ChartFrame("Surface Map - "
    + (Concentration.testing ? "TESTING using "
    + Concentration.testfile : currentFile.getName()), chart);
frame.pack();
frame.setVisible(true);
4

1 に答える 1

1

次の 2 つのオプションがあります。

  1. それら を JFreeChart の 3D 3D Lib として表します

  2. あなたが求めていることを正確に行うクラス:XYBlockRendererを使用する必要があります。このコードが記載されている JFreeChart デモ コレクションをダウンロードできます。(クラスのソースコードはこちら)非常によく似た 4D の完全なコード例もあります。

于 2012-08-31T09:53:21.153 に答える