Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7713895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:59:12+00:00 2026-06-01T01:59:12+00:00

I have chart.png with data in it that I would like to put a

  • 0

I have chart.png with data in it that I would like to put a simple X – Y axis on with some labeling. I also would like to try not to use any external software that doesn’t come with java. I’m allowed to use jfreechart but if there is a way to make it look nice, while just using some plan java code, that would be better. Does anyone have a good idea about how to do this sort of thing?

Update: Something like this but the data would be color coded with rgb values and of course there would be no axis / labeling.

pyplot latency example
(source: goldb.org)

This graph is just an example it looks nothing like what my actual graphs look like… My real graphs can have every rgb color value in them. I know how to create the plot, I just don’t know how to put axis / labeling on the BufferImage that I’ve created

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:59:13+00:00Added an answer on June 1, 2026 at 1:59 am

    I don’t think modifying a static image will work very well, as it will inevitably lead to registration errors and mismatched styles. Instead, integrate any rendering into the chart’s creation. Using the approach outlined here, the sscce below illustrates a few of the ways to customize the rendered shapes, colors and axes as desired.

    Addendum: To color individual items, the API recommends the approach shown here, in which a custom renderer overrides getItemPaint(). Color.getHSBColor() is used to create a full spectrum of colors.

    Response Time chart

    Here is the original, default renderer for comparison:

    Response Time chart

    import java.awt.Color;
    import java.awt.EventQueue;
    import java.awt.Paint;
    import java.awt.Shape;
    import java.awt.geom.Ellipse2D;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Random;
    import javax.swing.JFrame;
    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartPanel;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.axis.ValueAxis;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.chart.plot.XYPlot;
    import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
    import org.jfree.data.xy.XYDataset;
    import org.jfree.data.xy.XYSeries;
    import org.jfree.data.xy.XYSeriesCollection;
    
    /** @see https://stackoverflow.com/q/9843451/230513 */
    public class ResponseTime {
    
        private static final int N = 600;
        private static final String title = "ResponseTime";
        private static final Random random = new Random();
        private static final Shape circle = new Ellipse2D.Double(-3, -3, 6, 6);
        private static final Color line = Color.gray;
    
        private ChartPanel createPanel() {
            JFreeChart chart = ChartFactory.createXYLineChart(
                title, "Elapsed Time (secs)", "Response Time (secs)",
                createDataset(), PlotOrientation.VERTICAL, true, true, false);
            XYPlot plot = chart.getXYPlot();
            MyRenderer renderer = new MyRenderer(true, true, N);
            plot.setRenderer(renderer);
            renderer.setSeriesShape(0, circle);
            renderer.setSeriesPaint(0, line);
            renderer.setUseFillPaint(true);
            renderer.setSeriesShapesFilled(0, true);
            renderer.setSeriesShapesVisible(0, true);
            renderer.setUseOutlinePaint(true);
            renderer.setSeriesOutlinePaint(0, line);
            ValueAxis range = plot.getRangeAxis();
            range.setLowerBound(0.5);
            return new ChartPanel(chart);
        }
    
        private static class MyRenderer extends XYLineAndShapeRenderer {
    
            private List<Color> clut;
    
            public MyRenderer(boolean lines, boolean shapes, int n) {
                super(lines, shapes);
                clut = new ArrayList<Color>(n);
                for (int i = 0; i < n; i++) {
                    clut.add(Color.getHSBColor((float) i / n, 1, 1));
                }
            }
    
            @Override
            public Paint getItemFillPaint(int row, int column) {
                return clut.get(column);
            }
        }
    
        private XYDataset createDataset() {
            XYSeriesCollection result = new XYSeriesCollection();
            XYSeries series = new XYSeries("Series 1");
            for (double x = 0; x < N - 1; x++) {
                series.add(x, f(x));
            }
            series.add(25, 1.75); // outlier
            result.addSeries(series);
            return result;
        }
    
        private double f(double x) {
            double y = 0.004 * x + .75;
            return y + random.nextGaussian() * y / 10;
        }
    
        private void display() {
            JFrame f = new JFrame(title);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(createPanel());
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        }
    
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    new ResponseTime().display();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data that always looks something like this: alt text http://michaelfogleman.com/static/images/chart.png I need
I have some data in mysql that I load up in php and draw
Right Now I have this chart: https://i.stack.imgur.com/xyyNX.png I'd like to get the vertical grid
I have a chart generated from Google Charts that can be found here: Chart
I have a chart on a Windows Form with several line graphs. I would
I have a chart (code to replicate will be below) that has two lines
I have a line chart that is updated every so and so seconds, similar
I have a pie chart in BIRT and about 80 data points. I'm looking
I want to create a component which can be used like: <mc:chart data=#{bean.data} width=200
I am rolling my own simple web-based perfmon, I am not happy with some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.