Jfreechart 小记

这个博客展示了如何使用JFreechart库创建一个显示温度数据的图表。通过创建XYPlot并设置不同轴的数据,然后应用不同的渲染器,如XYLineAndShapeRenderer,来展示温度随时间的变化。代码中提供了创建数据集、设置轴标签和调整图表样式的方法。
摘要由CSDN通过智能技术生成


package org.jfree.chart.line;
import java.awt.Color;

import javax.swing.JPanel;

import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.NumberTickUnit;
import org.jfree.chart.axis.SymbolAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.renderer.xy.XYSplineRenderer;
import org.jfree.data.RangeType;
import org.jfree.data.time.Minute;
import org.jfree.data.time.RegularTimePeriod;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RectangleInsets;
import org.jfree.ui.RefineryUtilities;

/**
 * 
 * A demo showing a line chart drawn using spline curves.
 */
public class TemperatureChart extends ApplicationFrame {

    private static float[] TemperatureData;
    private static float nodata;
    /**
     * Creates a new instance of the demo application.
     *
     * @param title  the frame title.
     */
    public TemperatureChart(String title,float[] temperature,float nodata) {
        super(title);
        this.TemperatureData = temperature;
        this.nodata = nodata;
        JPanel content = createDemoPanel();
        content.setPreferredSize(new java.awt.Dimension(300, 500));
        getContentPane().add(content);
    }

    /**
     * Creates a panel for the demo (used by SuperDemo.java).
     *
     * @return A panel.
     */
    public static JPanel createDemoPanel() {
        
        //轴线数值为给定数值
            SymbolAxis ySymbolAxis1 = new SymbolAxis("hPa", new String[] {
                "1000", "950", "920", "850", "780", "700", "620", "500", "400", "300",
                "250", "200", "150", "100", "70", "50", "30", "20", "10", "5"
            });
        //给定数值的索引起始数值 0,1,2,3......
            ySymbolAxi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值