Results 1 to 5 of 5

Thread: graph

  1. #1
    shazibenga is offline Member
    Join Date
    Aug 2016
    Posts
    3
    Rep Power
    0

    Default graph

    I m real new to java.I want to know how can one create a graph where on x-axis =0,.....,1 and y-axis=0,.......,1000.now i want to know how to create such graph can be produce base on the number step you have enter(even grid).where the user can input the number of step but this steps are in within this interval on x-axis=[0,1],and on y-axis=[0,1000].please guys help!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: graph

    How is the graph to be displayed?
    Do you want to write the code or do you want to use a package to draw the graph?

    What have you tried?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    shazibenga is offline Member
    Join Date
    Aug 2016
    Posts
    3
    Rep Power
    0

    Default Re: graph

    I want to write the code and the graph should be like the graph of y=sqrt{x}.

  4. #4
    shazibenga is offline Member
    Join Date
    Aug 2016
    Posts
    3
    Rep Power
    0

    Default Re: graph

    i have this code:
    /*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */
    package fuctiongraph;

    /**
    *
    * @author Moody
    */
    public class FuctionGraph {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {

    // number of line segments to plot
    int n = Integer.parseInt(args[0]);

    // the function y = sin(4x) + sin(20x), sampled at n+1 points
    // between x = 0 and x = pi
    double[] x = new double[n+1];
    double[] y = new double[n+1];
    for (int i = 0; i <= n; i++) {
    x[i] = Math.PI * i / n;
    y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]);
    }

    // rescale the coordinate system
    StdDraw.setXscale(0, Math.PI);
    StdDraw.setYscale(0.0, 1.0);

    // plot the approximation to the function
    for (int i = 0; i < n; i++) {
    StdDraw.line(x[i], y[i], x[i+1], y[i+1]);
    }
    }
    }



    please if anyone can help

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: graph

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.

    The code doesn't have its import statements but
    It looks like that code uses 3rd party packages and classes that not many people here are familiar with.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Bar Graph
    By Gavin Fraser in forum Java 2D
    Replies: 4
    Last Post: 07-01-2013, 05:37 AM
  2. Replies: 16
    Last Post: 03-21-2012, 09:41 AM
  3. ECG Graph
    By bharath333 in forum Java Applets
    Replies: 4
    Last Post: 02-14-2009, 10:26 PM
  4. Bar Graph
    By Zosden in forum Advanced Java
    Replies: 2
    Last Post: 04-28-2008, 06:52 AM
  5. Help with graph's bar
    By coco in forum Java 2D
    Replies: 1
    Last Post: 08-07-2007, 07:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •