Using values to create a scatter plot in a character array

Ok, I am fairly new to the language and i am working ona program that will first, get the users input of how many values and the x and y of each value, it will store it into a 2d array and also have the x-squared value and X*Y value. I have all the entry of the data working and the calculation for the line of best fit works correctly.
What i need help with is, I want to take those values and store them into a character array that will display the points where they belong with a '*'. I also need to make the graph lines on the left and bottom. If the values are less than 10 for the x or y, i need to make them 10. The Y line needs to be rounded to the next highest 10s place if its over 10. I have tried a few things and i realised that it is completly wrong..
public void graph(int[][] grid, int n)
            int highY = 0;
            for(int x=0;x<n; x++)
             if (grid[x][1] > highY)
                highY = grid[x][1];
         char[][] output = new char[n+1][highY+1];
         for(int z=0; z<highY+1; z++)
             output[z][0]='+';
         for(int w=0; w<n+1; w++)
             output[n][w]='+';
         int tempx=1; int tempy=1;
         output[tempx][tempy]='*';
         while(tempx<n+1)
             tempy++;
             if(tempy==highY+1)
                 tempx++;
                 tempy=0;
             output[tempx][tempy]='*';
         System.out.println();
           for (int I=0; I<n+1; I++)
                  for (int J=0; J<highY+1; J++)
                      System.out.print(output[I][J]);
                      System.out.println();
}Grid is the grid of the values, and for the [x][1] is all the Y values going down, [x][0] is the X values. the x would go up to however many values there are. Again, i know the code above is wrong.
Any thoughts or suggestions would be appreciated. Also, if you need any more info from what i have done please ask.

Big El,
I think you can ditch the RGB To Color block, if that's what you're using.
If I understand your description, what you need to do is use Interleave 1D Arrays to combine your three sine arrays together into one long array. Then use Draw Flattened Pixmap to turn the array into a picture. You can use Bundle By Name to stick your interleaved array into the image data cluster, and also make sure to specify 24-bit image depth and an appropriate bounding box.
Hope that makes sense,
John

Similar Messages

  • Designate data points in scatter plots

    Hey,
    I`ve made a correspondence analysis in excel and want to get a scatter plot as .eps-file.
    I`ve imported the X and Y values in Illustrator and created a scatter plot. Now I would like
    to represent the numbers of data points (like in the illustration below). Is this even possible?
    If so, how? Various tutorials didnt help.
    Thanks for the help!
    Heiko

    That's possible. See http://www.m-server.de/m_g/Scatter%20graph-cs5.ai.zip
    How to create a graph design:
    http://help.adobe.com/en_US/illustrator/cs/using/WS3f28b00cc50711d9fc86fa8133b3ce158e-8000 .html#WS714a382cdf7d304e7e07d0100196cbc5f-61a3a

  • How do I do a scatter plot?  Plus, blank chart isn't blank!

    Something strange is going on with my Numbers app...
    But, before I get to that, I'm seeking confirmation on how to create a scatter plot.
    I have data arranged as such:
    Year     Rate
    January 2009     7.8
    February 2009     8.3
    March 2009     8.7
    April 2009     8.9
    etc.
    (formatting looks weird, but it's two columns)
    1.  Don't I simply select the variable names and the data, and then tap the + sign and scroll down for the scatter plot?  (Skipping the line chart icon, but tapping the one below that.)
    Alas, every time I do that I end up with two series of data, with a legend at the top that labels the two series as 2009 and 2011!!  In other words, not a scatter plot and not the right variable names (there shouldn't be a series legend in any case).
    I've tried just selecting the variables and data, skipping the variable names, but get the same result.
    2.  Now, here's where things get weird.  I de-selected the data and then tried creating a blank chart, to which I would add data.  That did not create a blank chart, but a virtually identical chart to the one before.
    I'm now wondering if somehow something's gotten corrupted or I inadvertently set a default chart that Numbers isn't overriding.
    Any and all suggestions welcome!
    3.  Oh, and by the way, is there any way of turning off the "Tap the chart to add data" message that appears each time and overlays the chart?  It's a nuisance! 

    Ok I got it to work. What I did was replace the bundle function of the waveforms with a build array function. This broke my clear history property node but I fixed that by creating a new control. Now I'm going to try it again from scratch to figure out what happened
    Using LabVIEW 2010SP1 and TestStand 4.5

  • How to I insert a line of best fit on a scatter plot????

    I have data already organized in tables, and I created a scatter plot. NOw I need to insert a line of best fit and get the equation. How do I do this??? I already calculated a and b (for y=a+bx) but I have no idea how to insert it on the plot. Every search tells me to "insert a trendline"..... but numbers doesnt have that function. Help please???

    Open inspector
    Go to chart tab
    Series
    Click on the "Advanced" to reveal the menu
    Trendline
    Choose the desired trendline (linear etc)
    Hope this helps.
    Dimitris

  • Sort x values highest to lowest in scatter plot?

    I want to do a simple scatter plot, which actually works fine and looks like this:
    The only problem is, I have to sort the x axis the other way round, starting with 24 copies going down to 10. Anybody got ideas?
    C.

    Hi C,
    Would this work?
    The method requires an auxiliary column in the data table and one edit to the chart. I added a second edit to the chart, adding weight to the connecting lines between data points, but that one is strictly cosmetic.
    Auxiliary column in the table:
    Insert a new column before column B. It will become column B.
    Formula:
    B2: =24-A
    24 is the maximum value in column A. "A" references the column A cell on the same row as the formula.
    Fill down to the bottom of column B. Results as shown. After creating the chart, this column may be hidden.
    Chart:
    Select cells B2:E7.
    Select Scatter Chart from the Charts button.
    When the chart is generated And still selected), click the gear icon at the top left of the selected cells and choose Share X values.
    Select the box containing the x axis labels. Press delete to delete this box.
    Click the Text box button in the Toolbar to insert a Text box.
    Enter 10 in the Text box. Adjust the width of the box to a loose fit around the number.
    With the box selected, press command-D seven times to create another seven identical boxes.
    Edit the contents of these boxes to contain the even numbers from 10 to 24.
    Carefully place the box containing 10 directly below the first data point on the chart, and as far below the x axis as you want the row of labels to appear.
    Carefully place the box containing 24 directly below the last data point on the chart, and slightly lower on the page than the box containing 10.
    Place the other boxes in ascending order between and slightly below the two boxes already placed.
    Select all eight of these boxes, but nothing else.
    Go Arrange (menu) > Align Objects > Top
    Go Arrange > Distribute Objects > Horizontally
    Go Arrange > Group
    If desired, adjust the weight and colours of the data point icons and connecting lines.
    Note: Any revisions to the data will likely require repeating the construction above.
    Data table and chart constructed using Numbers '09 v2.3
    Regards,
    Barry

  • Scatter plot using time series function - Flash charting

    Apex 3 + XE + XP
    I am trying to build a time series scatter plot chart using flash chart component.
    Situation :
    On each scout date counts are taken within each crop. I want to order them by scout dates and display them in a time series chart. Each series represents different crop.
    I am posting the two series queries I used
    Queries:
    Series 1
    select     null LINK, "SCOUTDATES"."SCOUTDATE" LABEL, INSECTDISEASESCOUT.AVERAGECOUNT as "AVERAGE COUNT" from     "COUNTY" "COUNTY",
         "FIELD" "FIELD",
         "VARIETYLIST" "VARIETYLIST",
         "INSECTDISEASESCOUT" "INSECTDISEASESCOUT",
         "SCOUTDATES" "SCOUTDATES",
         "CROP" "CROP"
    where "SCOUTDATES"."CROPID"="CROP"."CROPID"
    and     "SCOUTDATES"."SCOUTID"="INSECTDISEASESCOUT"."SCOUTID"
    and     "CROP"."VARIETYID"="VARIETYLIST"."VARIETYLISTID"
    and     "CROP"."FIELDID"="FIELD"."FIELDID"
    and     "FIELD"."COUNTYID"="COUNTY"."COUNTYID"
    and      "INSECTDISEASESCOUT"."PESTNAME" ='APHIDS'
    and     "VARIETYLIST"."VARIETYNAME" ='SUGARSNAX'
    and     "COUNTY"."COUNTNAME" ='Kings' AND CROP.CROPID=1
    order by SCOUTDATES.SCOUTDATE' ASC
    Series 2:
    select     null LINK, "SCOUTDATES"."SCOUTDATE" LABEL, INSECTDISEASESCOUT.AVERAGECOUNT as "AVERAGE COUNT" from     "COUNTY" "COUNTY",
         "FIELD" "FIELD",
         "VARIETYLIST" "VARIETYLIST",
         "INSECTDISEASESCOUT" "INSECTDISEASESCOUT",
         "SCOUTDATES" "SCOUTDATES",
         "CROP" "CROP"
    where "SCOUTDATES"."CROPID"="CROP"."CROPID"
    and     "SCOUTDATES"."SCOUTID"="INSECTDISEASESCOUT"."SCOUTID"
    and     "CROP"."VARIETYID"="VARIETYLIST"."VARIETYLISTID"
    and     "CROP"."FIELDID"="FIELD"."FIELDID"
    and     "FIELD"."COUNTYID"="COUNTY"."COUNTYID"
    and      "INSECTDISEASESCOUT"."PESTNAME" ='APHIDS'
    and     "VARIETYLIST"."VARIETYNAME" ='SUGARSNAX'
    and     "COUNTY"."COUNTNAME" ='Kings' AND CROP.CROPID=4
    order by SCOUTDATES.SCOUTDATE' ASC
    Problem
    As you can see the observations are ordered by scout date. However when the chart appears, the dates dont appear in order. The chart displays the data from crop 1 and then followed by crop 4 data, which is not exactly a time series chart. Does flash chart support time series or they have no clue that the data type is date and it should be progressive in charting ? I tried to use to_char(date,'j') to converting them and apply the same principle however it did not help either.
    Any suggestions ?
    Message was edited by:
    tarumugam
    Message was edited by:
    aru

    Arumugam,
    All labels are treated as strings, so APEX will not compare them as dates.
    There are two workarounds to get all your data in the right order:
    1) Combine the SQL statements into single-query multi-series format, something like this:
    select null LINK,
    "SCOUTDATES"."SCOUTDATE" LABEL,
    decode(CROP.CROPID,1,INSECTDISEASESCOUT.AVERAGECOUNT) as "Crop 1",
    decode(CROP.CROPID,4,INSECTDISEASESCOUT.AVERAGECOUNT) as "Crop 4"
    from "COUNTY" "COUNTY",
    "FIELD" "FIELD",
    "VARIETYLIST" "VARIETYLIST",
    "INSECTDISEASESCOUT" "INSECTDISEASESCOUT",
    "SCOUTDATES" "SCOUTDATES",
    "CROP" "CROP"
    where "SCOUTDATES"."CROPID"="CROP"."CROPID"
    and "SCOUTDATES"."SCOUTID"="INSECTDISEASESCOUT"."SCOUTID"
    and "CROP"."VARIETYID"="VARIETYLIST"."VARIETYLISTID"
    and "CROP"."FIELDID"="FIELD"."FIELDID"
    and "FIELD"."COUNTYID"="COUNTY"."COUNTYID"
    and "INSECTDISEASESCOUT"."PESTNAME" ='APHIDS'
    and "VARIETYLIST"."VARIETYNAME" ='SUGARSNAX'
    and "COUNTY"."COUNTNAME" ='Kings'
    AND CROP.CROPID in (1,4)
    order by SCOUTDATES.SCOUTDATE ASC2) Union the full domain of labels into your first query. Then the sorting will be applied to the full list, and the values of the second series will be associated with the matching labels from the first.
    - Marco

  • How can i relocate R^2 and equation values in scatter plot?

    hey, i used Numbers to crate scatter plot and findig trendline and R^2 values.
    the problem is that numbers automaticly put the values in the left side of the plot, and i couldnt find a way to edit their location.
    there is a way to do that?
    btw i usees the last version with OSX 10.9.

    I do not see how to move these either.  Looks like intent is that the user NOT be able to move as there is a formatter for the R^2 value and the equation when they are selected.

  • Iam using a table in numbers to plot daily graph lines. If I fill a cell with a text box  at say zero it plots the graph. I can't actually set the cell value until the actual day but the graph plots it at zero when I don't want it to plot anything. Is tho

    I am using a table in Numbers to plot daily graph lines. Mood swings of how I am on the day, i"m a depressive.
    If I fill a cell with a step box at say zero it plots the graph. I can't actually set the cell value until the actual day but the graph plots it at zero when I don't want it to plot anything. Is there a work around. so thatbgraph only plots on the day?

    The answer is (sort of) in your subject, but edited out of the problem statement in the body of your message.
    When you use a stepper or a slider, the value in the cell is always numeric, and is always placed on the chart if that cell is included in the range graphed by the chart.
    But if you use a pop-up menu cell, you can specify numeric or text values in the list of choices for in the menu. Numeric values will be shown on the chart. Text values will not.
    For the example, the values list for the pop-up menu was:
    5
    3
    1
    Choose
    -1
    -3
    -5
    The first pop-up was set to display Choose, then the cell was filled down the rest of the column. Any text value (including a single space, if you want the cell to appear blank) may be used instead of Choose.
    For charts with negative Y values, the X axis will not automatically appear at Y=0. If your value set will include negative values, I would suggest setting the Y axis maximum and minimum to the maximum and minimum values on your menu list, rather than letting Numbers decide what range to include on the chart. Place a line shape across the chart at the zero level, and choose to NOT show the X axis.
    Regards,
    Barry

  • What are required feilds values for creating a sales order using va01?

    What are required feilds values for creating a sales order using va01?
    Please give examples if possible.

    Hi,
    go through this URL:
    <a href="http://web.mit.edu/cao/www/SB2002/CR/VA01.htm">http://web.mit.edu/cao/www/SB2002/CR/VA01.htm</a>
    Hope this will help you.
    Thanks
    Shiva

  • Trendline in Scatter plot

    Hi,
    I have a couple question on Power View 2010
    1. I want to know if I can plot regression Trendlines(Linear/polynomial/power) on scatter plot?
    2. Navigation between pages- Is it possible to navigate between report pages in Power View 2010 by passing parameters from the first page to the next page?
    3. I have a report that has 3 pages. I want to create 2 pages in SSRS 2012 and one in Power View 2010. Is it possible to navigate between these applications and also pass parameters in the URL?
    Thanks in advance.
    Ankit

    The reason why it hangs is because you have 2 event structures inside a loop. You should only have one event structure in a loop. This is documented in the LabVIEW Help. With 2 event structures one of them will block the other.
    Your code is also about 3 times larger than it needs to be:
    To create the array of names for the dropdowns you only need to autoindex a for-loop from the 2D array of data and use the Format Into String function.  You don't actually need to use the values - you only need to autoindex the for-loop.
    Using Delete From Array and Reshape Array just to pull out a row is simply silly (not to mention a Rube Goldberg). That's what Index Array is for.
    In the Cursor Move event case you only need one function: Index Array. The point index is already available to you from the event case's data.
    Half of the code really belongs outside of the while loop since none of that data ever changes, so what's the point of regenerating it each time?
    Instead of using 2 Index Array functions just to get the list of names, wire a True to the Read From Spreadsheet File's transpose? input and use the first row output.
    I've attached a simplified version of your VI.
    Attachments:
    PCoption2_MOD.vi ‏34 KB

  • Scatter plot graphs, more than 2 series possible?

    It's been very difficult for me to put 3 or 4 series of data in scatter graphs and connect the dots with lines as in Excel, it just doesn't allow me. I made a graph before using line graph model but it turns out that in the x axis (which in this case is time in weeks) I need to show the distance proportionally (i.e. 0,2,6,12 and 16 weeks) and I can't find how to do it with a simple line graph. Tried in excel and is easy using the scatter plot graph (very simple, using exactly the same data arrangement). But numbers does not accept the series of data (it only accepts X,Y per series) and in second place there is not lines connecting the dots. Any of you guys have a suggestion?. I'd really prefer to use numbers bit do not why is so difficult to scatter graph the data. Thanks

    The default for X-Y pairs can actually be pretty handy, though often it is not. You can easily turn it into one X and a bunch of Y's. Connecting lines are also available.
    My assumption from your post is you have a column of X values and several columns of Y values.
    1) All data for a scatter plot must be in "normal" data cells, none in header cells.
    2) Select all the X & Y data and create a scatter chart.
    3) There is a "gear" at the top left of the colored box in the table that indicates the data in the chart. Click it and choose to share X values. Now you should have one column labeled "X" and several labeled "Y" and your chart will show each Y as a separate series.
    4) With the chart selected (the whole chart, not one of the series), go to the Chart tab of the inspector, go to the series tab, look for the words "connect points" and choose what kind of line you want to connect the points. Alternatively or additionally, you could make trendline curves by clicking on "advanced". Also, you can do them one at a time and choose different settings for each series by selecting each series separately.
    If you have gaps in your Y data, it will not connect the points on either side of the gap, you will have a missing line segment.
    If your X data is unsorted, some connecting lines may go right-to-left, not left-to-right.

  • Label each point in scatter plot

    Hi There,
    I am plotting a set of data (in x,y format) on a scatter plot. Is there a way in labview such that when i move mouse over some dot it can tell me information about that dot (like the name of that set).
    Thanks in advance
    Yogesh 
    PS: i am using Labview 8.2 
    Solved!
    Go to Solution.

    The reason why it hangs is because you have 2 event structures inside a loop. You should only have one event structure in a loop. This is documented in the LabVIEW Help. With 2 event structures one of them will block the other.
    Your code is also about 3 times larger than it needs to be:
    To create the array of names for the dropdowns you only need to autoindex a for-loop from the 2D array of data and use the Format Into String function.  You don't actually need to use the values - you only need to autoindex the for-loop.
    Using Delete From Array and Reshape Array just to pull out a row is simply silly (not to mention a Rube Goldberg). That's what Index Array is for.
    In the Cursor Move event case you only need one function: Index Array. The point index is already available to you from the event case's data.
    Half of the code really belongs outside of the while loop since none of that data ever changes, so what's the point of regenerating it each time?
    Instead of using 2 Index Array functions just to get the list of names, wire a True to the Read From Spreadsheet File's transpose? input and use the first row output.
    I've attached a simplified version of your VI.
    Attachments:
    PCoption2_MOD.vi ‏34 KB

  • Polynomial fitting for scatter plot

    Hi all, 
    I was wondering if there is any way to generate a polynomial fit to a scatter plot just like in excel. The data I am trying to fit has several y values for each x value. 
    Thanks
    Krish
    Solved!
    Go to Solution.

    Well, my "solution" above is a bit misleading, because the polynomial fit of course does NOT depend on the x ordering. If the x-values are scranbled as in your case, a maybe better solution would be to simply create a linear x-ramp over the data range and use polynomial evaluation to calculate a smooth best fit line. This has also the advantage tha a smooth curve is generated even if the data points are sometimes far apart.
    Here is one possible modification to show the technique.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Scatterplot_fitting_MODCA2.vi ‏13 KB

  • Axis scale for scatter plots

    I'm trying to create a specialized scatter plot, which functions similar to Excel's scatter plot. I'm having problems determining what the min and max values should be for the axes. I would like the program to determine from the input data what the initial min and max values should be on the x- and y-axis, the user can adjust later.
    So, I don't want the program to just look at the maximum value imported and round up. For instance, data = {523.7, 514.4, 271.8, 128.5}. The max value is 523.7, round up to 524. Instead, I would like to program to make 600 the largest value on the axis, because that makes it nice round number for the user to view the dataset.
    Then, I thought it really depends on the range of the data. For instance, data = {523.4, 523.8, 523.2, 522.8, 523.9}. Here, the range is very small, so it doesn't make sense to have 600 the largest value on the scale. The largest value should be 524 or 525, and the small value on the axis scale should be 521 or 522.
    Has anyone else ever worked with this problem, or have a good solution? I would really appreciate it, I've spend way too many days working on this.
    Thank you,
    Joe

    This is off the top of my head and based on a slight variation of your data.
    data: 52.34, 52.38, 52.32, 52.28, 52.39
    min=52.28 max=52.39 range=0.11
    Looking at the range we see it is "on the order of" 0.1. Ie, it is closer to the next lower power of 10 (0.1) than it is to the next higher one (1.0). So we round min down to the next lowest multiple of 0.1 (52.2) and round max up (52.4). 52.2 and 52.4 can serve as the nice numbers.
    The range is just a little bigger than a power of 10, so it might be a good idea to check what happens when it's a little less.
    data: 135 226 141 143 etc
    min=135 max=226 range=91
    range is on the order of 100, and the nice numbers are 100 and 300.
    As a variation on this strategy if we always find the power of 10 below the range (10 in the second example) we get a tighter fit but the numbers are slightly less nice - 130 and 220.
    (I'm pretty sure I've seen - and used! - some java software from the Internet somewhere to find the best scale for axes, so it might pay to look around)
    Had to edit my second example and, while I was waiting, found what I have used for this sort of thing: http://geosoft.no/software/index.html (The NiceNumbers class - it finds numbers along a range suitable for major and minor "ticks" but, if memory serves me correctly it extends the range so that the ends are nice too.)

  • Add point to scatter plot each time a button is pressed

    Hi folks,
    Apologies if this has been answered elsewhere, I am new to LabVIEW and trying to get an experiment up-and-running quickly!
    I was wondering if anybody would have general pointers or code examples on how to create a 2D scatter plot, to which a data point is added each time a button is pressed.
    I am measuring a gauge pressure and a force (from a load cell). I would like the scatter plot to add another data point each time I press a button, so that a history of my datapoints is shown. It would also be quite nice is this plot could then be exported as a .jpg using another button, but this is not critical. 
    A seperate button would also be available to clear the scatter plot.
    My current thinking is that this can be done by 'adding to an array', - presumably the chart would refresh each time an element was added to the array, but I am struggling a little bit with how to do this.
    If anybody has any suggestions, I would be very grateful for them.
    Many thanks,
    Euan

    Hi Euan,
    If you want to have your data shown in real time (and I'm assuming you do) then you'll need to use a Waveform Chart. The chart is able to update itself each time a value is written to it.
    The event structure is your friend here: you can write a case to update the chart each time a button is pressed. You can also create cases for the other situations you mentioned (clear chart, export jpg etc.)
    If you don't care about the chart updating in real time then you can use your idea of updating an array and then use a Waveform Graph to plot the datapoints at the end of your program.
    Take a look at the LabVIEW Basics course and the Examples for info on how to implement the event structure. If you run into any problems just post your VI and we'll see if we can't help you fix them.
    -CC
    "If anyone needs me, I'll be in the Angry Dome!"

Maybe you are looking for

  • Why can't I 'Export Using Compressor Settings' in FCPX?

    It keeps telling me I have to buy Compressor, which I did from the App Store.

  • Strange error - please help

    Hi all, I've created a form for use within my company using LiveCycle ES version 8.2.  I created the form and then selected 'extend features in adobe reader'. The problem:  Most are able to use the form just fine but sometimes when it is sent to our

  • Any donations software apps for OS X?

    Im sorry, I didnt know where else to post this, but my church is thinking of switching to Macs. They currently use a program called Membership Plus to keep records of donations/offerings/etc. for tax purposes and such. I need to find a Mac equivalent

  • OSX 10.4.9 Server, strange errors

    I have a server setup with correct permissions with ACL. Everything seems to be working fine, however multiple computers in the department keep turning up with read only permissions. I will check the permissions on the server, they will be 100% corre

  • Time Machine backup crashes my MBP since I've installed Mountain Lion

    Hello, I've got a MBP (1.5 years old) and do my back-ups on Time Capsule. Recently I upgraded to Mountain Lion and since then I've come accross some back-up issues: 1. I've got the error message containing the "sparsebundle already in use" wording 2.