All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.finmath.plots.jfreechart.JFreeChartUtilities Maven / Gradle / Ivy

Go to download

finmath lib plot extensions provide convenient plotting methods by providing consistent wrappers to plot libraries (like JFreeChart or JavaFX).

The newest version!
/*
 * Created on 26.12.2004
 *
 * (c) Copyright Christian P. Fries, Germany. Contact: [email protected].
 */

package net.finmath.plots.jfreechart;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;

import javax.imageio.ImageIO;

import org.apache.commons.math3.linear.RealMatrix;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.LogarithmicAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.AbstractXYItemRenderer;
import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
import org.jfree.chart.renderer.xy.XYBlockRenderer;
import org.jfree.chart.title.PaintScaleLegend;
import org.jfree.chart.ui.RectangleEdge;
import org.jfree.chart.ui.RectangleInsets;
import org.jfree.data.xy.DefaultXYZDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

import net.finmath.plots.util.JFreeChartToFile;

/**
 * Some utilities for JFreeChart
 *
 * @author Christian Fries
 */

public class JFreeChartUtilities {

	public static JFreeChart getContourPlot(final String labelX, final String labelY, final String labelZ, final RealMatrix dataMatrix) {
		/*
		 * Generate contour plot
		 */
		final int			numberOfValues	= dataMatrix.getColumnDimension()*dataMatrix.getRowDimension();
		final double[]	xValues			= new double[numberOfValues];
		final double[]	yValues			= new double[numberOfValues];
		final double[]	zValues			= new double[numberOfValues];
		int valueIndex = 0;
		for(int col=0; col




© 2015 - 2025 Weber Informatics LLC | Privacy Policy