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 6391895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:44:40+00:00 2026-05-25T03:44:40+00:00

Any suggestions over how to set Range for X-Axis and Y-Axis. My X-Axis Range

  • 0

Any suggestions over how to set Range for X-Axis and Y-Axis.

My “X-Axis” Range is from “0.00 to 1.00” with difference of “0.05”. I mean 0.00 0.05 0.10 0.15…..0.90 0.95 1.00

My “Y-Axis” Range is from “0.0 to 1.0” with difference of “0.1”. I mean 0.0 0.1 0.2 0.3 0.4………0.9 1.0

I tried doing this Way, but it’s not reflecting on the Graph; I don’t know how to apply it to ChartFactory.createScatterPlot().

final NumberAxis domainAxis = new NumberAxis("X-Axis");
domainAxis.setRange(0.00,1.00);
domainAxis.setTickUnit(new NumberTickUnit(0.1));
final NumberAxis rangeAxis = new NumberAxis("Y-Axis");
rangeAxis.setRange(0.0,1.0);
rangeAxis.setTickUnit(new NumberTickUnit(0.05));

public  JPanel createDemoPanel() {
    XYDataset dataset1 = samplexydataset2();
    JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter Plot Demo",
        "X", "Y",dataset1, PlotOrientation.VERTICAL, true, true, false);
}

Any help regarding this would be great.

  • 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-05-25T03:44:41+00:00Added an answer on May 25, 2026 at 3:44 am

    I’m guessing your new NumberAxis instances aren’t being used by the plot; it may be easier to use the existing ones from the factory.

    enter image description here

    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.EventQueue;
    import java.awt.event.ActionEvent;
    import java.util.*;
    import javax.swing.AbstractAction;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import org.jfree.chart.*;
    import org.jfree.chart.axis.NumberAxis;
    import org.jfree.chart.axis.NumberTickUnit;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.chart.plot.XYPlot;
    import org.jfree.chart.renderer.xy.XYItemRenderer;
    import org.jfree.data.xy.XYDataset;
    import org.jfree.data.xy.XYSeries;
    import org.jfree.data.xy.XYSeriesCollection;
    
    /**
     * @see http://stackoverflow.com/questions/7231824
     * @see http://stackoverflow.com/questions/7205742
     * @see http://stackoverflow.com/questions/7208657
     * @see http://stackoverflow.com/questions/7071057
     */
    public class ScatterAdd extends JFrame {
    
        private static final int N = 8;
        private static final String title = "Scatter Add Demo";
        private static final Random rand = new Random();
        private XYSeries added = new XYSeries("Added");
    
        public ScatterAdd(String s) {
            super(s);
            final ChartPanel chartPanel = createDemoPanel();
            this.add(chartPanel, BorderLayout.CENTER);
            JPanel control = new JPanel();
            control.add(new JButton(new AbstractAction("Add") {
    
                @Override
                public void actionPerformed(ActionEvent e) {
                    for (int i = 0; i < N; i++) {
                        added.add(rand.nextDouble(), rand.nextDouble());
                    }
                }
            }));
            this.add(control, BorderLayout.SOUTH);
        }
    
        private ChartPanel createDemoPanel() {
            JFreeChart jfreechart = ChartFactory.createScatterPlot(
                title, "X", "Y", createSampleData(),
                PlotOrientation.VERTICAL, true, true, false);
            XYPlot xyPlot = (XYPlot) jfreechart.getPlot();
            xyPlot.setDomainCrosshairVisible(true);
            xyPlot.setRangeCrosshairVisible(true);
            XYItemRenderer renderer = xyPlot.getRenderer();
            renderer.setSeriesPaint(0, Color.blue);
            NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
            domain.setRange(0.00, 1.00);
            domain.setTickUnit(new NumberTickUnit(0.1));
            domain.setVerticalTickLabels(true);
            NumberAxis range = (NumberAxis) xyPlot.getRangeAxis();
            range.setRange(0.0, 1.0);
            range.setTickUnit(new NumberTickUnit(0.1));
            return new ChartPanel(jfreechart);
        }
    
        private XYDataset createSampleData() {
            XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
            XYSeries series = new XYSeries("Random");
            for (int i = 0; i < N * N; i++) {
                double x = rand.nextDouble();
                double y = rand.nextDouble();
                series.add(x, y);
            }
            xySeriesCollection.addSeries(series);
            xySeriesCollection.addSeries(added);
            return xySeriesCollection;
        }
    
        public static void main(String args[]) {
            EventQueue.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    ScatterAdd demo = new ScatterAdd(title);
                    demo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    demo.pack();
                    demo.setLocationRelativeTo(null);
                    demo.setVisible(true);
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Any suggestions on the best way to ensure thread safety when changing the properties
Any suggestions? Using visual studio in C#. Are there any specific tools to use
Any suggestions for good open source asp.net (C#) apps out there which meet as
Any suggestions on how to write repeatable unit tests for code that may be
Any suggestions on how to improve DataGridViewComboBoxColumn performace with large item sets? I've got
Any suggestions for an accurate Web Log analysis tool to generate reports on the
Any suggestions on why a VB6 program would be slower when compiled than when
any suggestions for a C# object pooling framework? requirements are multi-thread support and a
Any suggestions on how I can cleanup the following code pattern that repeats multiple
Any suggestions on whether fewer check constraints are better, or more? How should they

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.