我正在使用org.jzy3d
包(v 0.9)来创建Surface plots
. 这是我的代码:
int stepsX = 6;
Range rX = new Range(1,6);
int stepsY = 7;
Range rY = new Range(0,6);
Mapper mapper = new Mapper(){
@Override
public double f(double x, double y) {
return //My function to get z;
}
};
org.jzy3d.plot3d.primitives.Shape surface = Builder.buildOrthonormal(new OrthonormalGrid(rX, stepsX, rY, stepsY), mapper);
surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(), surface.getBounds().getZmax(), new org.jzy3d.colors.Color(1, 1, 1, .5f)));
surface.setFaceDisplayed(true);
surface.setWireframeDisplayed(false);
org.jzy3d.chart.Chart chart = new org.jzy3d.chart.Chart(Quality.Advanced,"swing");
chart.getScene().getGraph().add(surface);
IAxeLayout l = chart.getAxeLayout();
l.setXAxeLabel("Observation");
l.setYAxeLabel("Week");
l.setZAxeLabel("Rate");
l.setMainColor(org.jzy3d.colors.Color.GRAY);
JPanel p = new JPanel(new BorderLayout()); //another panel will be added to this panel and aligned left (BorderLayout.WEST)
p.add((JPanel)chart.getCanvas(),BorderLayout.CENTER);
...这就是我得到的:
我想进一步定制这个图表,但我真的不知道怎么做。
我特别想:
缩小图表以适合我的面板(在附图中您可以看到图表的底部不可见);
格式化轴标签(例如,z 轴显示 0.6 而不是 0.600000,x 轴显示 2 而不是 2.000 等等......);
反转颜色映射(例如,z 值较低时为红色,z 值较高时为蓝色/绿色)。