java – 使用colourmaps在2D图形中表示3D数据的JFreeChart
发布时间:2020-12-15 02:29:50 所属栏目:Java 来源:网络整理
导读:我目前正在尝试使用JFreeChart在2D图形中表示3D数据. 基本上,我有一个名为data [i] [j]的二维数组. i和j代表我想要绘制的y和x坐标. data [i] [j]的值表示频率值,我想在图中将其表示为颜色. 我不完全确定这样的东西被称为什么,但它看起来像这样: 现在我一直
我目前正在尝试使用JFreeChart在2D图形中表示3D数据.
基本上,我有一个名为data [i] [j]的二维数组. i和j代表我想要绘制的y和x坐标. data [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); 解决方法
您有两种选择:
>将它们表示为3d (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |