jmathplot - 旋转轴标签错位线图

时间:2013-11-11 09:41:33

标签: java swing user-interface plot jmathplot

我正在使用jmathplot绘制一些线条图。一切都适合我,但当我旋转轴标签时,图表将不对齐。我已经发布了这个问题here,但还没有人回答。

有什么建议吗?

SSCCE:

import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JFrame;

import org.math.plot.Plot2DPanel;
import org.math.plot.plotObjects.BaseLabel;

public class JMathPlotDemo {
    public static void main(String[] args) {
        JFrame myWindow = new JFrame("JMathPlotDemo");
        myWindow.setSize(new Dimension(400,400));
        myWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Plot2DPanel myPlot = new Plot2DPanel();
        myPlot.removePlotToolBar();
        for(int i = 0; i < 3; i ++){
            double[] x = new double[5];
            double[] y = new double[5];
            for(int j = 0; j < 5; j ++){
                x[j] = j;
                y[j] = Math.random()*10;
            }
                myPlot.addLinePlot("Line "+(i+1), x, y);
        }

        myPlot.setSize(400, 400);

        myPlot.getAxis(0).setLabelText("My x axis label");
        myPlot.getAxis(0).setLabelPosition(0.5, -0.15);
        myPlot.getAxis(1).setLabelText("My y axis label");
        myPlot.getAxis(1).setLabelAngle(-Math.PI / 2); 
        myPlot.getAxis(1).setLabelPosition(-0.15, 0.5);

        myPlot.addLegend(Plot2DPanel.SOUTH);
        BaseLabel title = new BaseLabel("JMathPlotDemo", Color.black, 0.5, 1.1);
        myPlot.addPlotable(title);
        myWindow.setContentPane(myPlot);
        myWindow.setVisible(true);
    }

}    

1 个答案:

答案 0 :(得分:1)

来自OP,因为我已经有一段时间了:

&#34;使用JFreeChart&#34;

解决了问题