Reputation: 21
i'm using jmathplot to paint some line plots. Everything works fine for me, but when i'm rotating the axis labels, the plots will be misaligned. I already posted this issue here but no one answered yet.
Any suggestions?
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);
}
}
Upvotes: 0
Views: 501
Reputation: 9708
From OP since hasn't been around for a while:
"problem solved by using JFreeChart"
Upvotes: 1