<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with #dataplotting - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23dataplotting</link>
      <pubDate>Sun, 08 Aug 2021 17:02:43 +0000</pubDate>
         <description>Tagged with #dataplotting - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23dataplotting/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Idea: R Language Mode for Processing</title>
      <link>https://forum.processing.org/two/discussion/21195/idea-r-language-mode-for-processing</link>
      <pubDate>Mon, 06 Mar 2017 09:30:17 +0000</pubDate>
      <dc:creator>gaocegege</dc:creator>
      <guid isPermaLink="false">21195@/two/discussions</guid>
      <description><![CDATA[<p>Hi, processing :)</p>

<p>R is an open source programming language and software environment for statistical computing and graphics. It <a rel="nofollow" href="http://www.tiobe.com/tiobe-index/">ranks 15th in TIOBE Index for February 2017</a>.</p>

<p>Processing.py helps python users to get in touch with visual arts easily and spreads the concept of processing foundation. Processing.R is a good way to expand the user base for processing and reduce learning curve for R users. It is win-win.</p>

<p>I have implemented a prototype: <strong><a rel="nofollow" href="https://github.com/gaocegege/Processing.R">github.com/gaocegege/Processing.R</a></strong> in Sep 2016. It is a demo for R mode, and GSoC is a good chance to make it usable and contribute to processing foundation.</p>

<p>Welcome for any suggestions and opinions and thanks for your browsing :)</p>

<p><img src="https://github.com/gaocegege/Processing.R/raw/master/raw-docs/img/editor.png" width="400" alt="image" /></p>

<p><img src="https://github.com/gaocegege/Processing.R/raw/master/raw-docs/img/demo.gif" width="300" alt="image" /></p>

<h4>About Me</h4>

<p>I’m a freshman in a master’s program in <a rel="nofollow" href="http://en.sjtu.edu.cn/">Shanghai Jiao Tong University</a>, my own research orientation is container-based OS virtualization (COS virtualization), so I have contributed to many container-based projects such as docker, kubernetes, runc and so on. I’m a heavy user of GitHub and know the workflow in GitHub.</p>

<p>GitHub: <a rel="nofollow" href="https://github.com/gaocegege">github.com/gaocegege</a></p>
]]></description>
   </item>
   <item>
      <title>To create a real time graph</title>
      <link>https://forum.processing.org/two/discussion/24117/to-create-a-real-time-graph</link>
      <pubDate>Thu, 14 Sep 2017 06:48:21 +0000</pubDate>
      <dc:creator>Nitin1992</dc:creator>
      <guid isPermaLink="false">24117@/two/discussions</guid>
      <description><![CDATA[<p>Hello all,</p>

<p>I am writing a graphical representation of movement/rotations of a motion sensor. I am able to write the code to print the values and graphical representation of rotation of sensor. But now i am stuck with plotting the graph for the same w.r.t the values real time. Following is the code,</p>

<pre><code>   //graphics object we will use to buffer our drawing
    PGraphics graphics;
    ToxiclibsSupport gfx;
    float[] q = new float[4];
    Quaternion quat = new Quaternion(1, 0, 0, 0);
    Quaternion quat1 = new Quaternion(1, 0, 0, radians(90));
    //window dimensions
    //int multiplicator = 100;
    //int window_x = 16*multiplicator;
    //int window_y = 9*multiplicator;
    int window_x = 1024;
    int window_y = 768;

    int lastCallLogic = 0; //absolute time when logic thread was called
    int lastCallRender = 0; //lastCallRender
    int lastCallMisc = 0;

    //time passed since last call 
    int deltaTLogic = 0;
    int deltaTRender = 0;

    //how often we already called the threads
    int countLogicCalls = 0;
    int countRenderCalls = 0;

    //used to know  how many calls since last fps calculation
    int countLogicCallsOld = 0;
    int countRenderCallsOld = 0;

        String inBuffer1,inBuffer2;

    //framerate of Logic/Render threads
    //-1 to run as fast as  possible. be prepared to melt your pc!
    int framerateLogic = 500;
    int framerateRender = 200;

    int framerateMisc = 1; //how often the framerate display will be updated
    int no_of_sensor = 2;
    Serial[] ports = new Serial[2];    // the serial ports
    float[] yaw = new float[no_of_sensor];
    float[] pitch = new float[no_of_sensor];
    float[] roll = new float[no_of_sensor];
    PFont f;
    void setup() {

      //init window
      //size(window_x, window_y); //creates a new window
      size(1024, 768, OPENGL); //creates a new window
      gfx = new ToxiclibsSupport(this);
       f = createFont("Arial",20,true);
      graphics = createGraphics(window_x, window_y);//creates the draw area
      frameRate(framerateRender); //tells the draw function to run
        ports[0] = new Serial(this, "COM6"/**Serial.list()[0]*/, 230400);  // upper arm : we will assume as of now
        ports[0].clear();
       textFont(f);
       textAlign(LEFT);
       fill(255,0,0);
      logicThread.start();

      println(Thread.currentThread().getName() +" : the MainThread is running and used to Render");
    }

    //draw function. This is our Render Thread
    void draw() {

      countRenderCalls++;

      graphics.beginDraw();

      //CODE TO DRAW GOES HERE
       background(0);
           text(roll[0],10,50);
        text(pitch[0],10,90);
        text(yaw[0],10,130);
        text(q[0],10,170);
        text(q[1],10,210);
        text(q[2],10,250);
        text(q[3],10,290);
      pushMatrix();
        translate(1024/4, 768/2, -50);
        scale(4,4,4);

       rotateZ(radians(pitch[0]));
        rotateX(radians(yaw[0]));
        rotateY(radians(roll[0]));
        buildBoxShape();

      popMatrix();
        pushMatrix();
        translate(3*(1024/4), 768/2, -50);
        scale(4,4,4);

        float[] axis = quat.toAxisAngle();
        rotate(axis[0], -axis[1], axis[3], axis[2]);
        //buildBoxShape();
        buildBoxShape();
      popMatrix();


      //-------------
      graphics.endDraw();
      image(graphics, 0, 0);
    }

    void buildBoxShape() {
      //box(60, 10, 40);
      noStroke();
      beginShape(QUADS);

      //Z+ (to the drawing area)
      fill(#00ff00);
      vertex(-30, -5, 20);
      vertex(30, -5, 20);
      vertex(30, 5, 20);
      vertex(-30, 5, 20);

      //Z-
      fill(#0000ff);
      vertex(-30, -5, -20);
      vertex(30, -5, -20);
      vertex(30, 5, -20);
      vertex(-30, 5, -20);

      //X-
      fill(#ff0000);
      vertex(-30, -5, -20);
      vertex(-30, -5, 20);
      vertex(-30, 5, 20);
      vertex(-30, 5, -20);

      //X+
      fill(#ffff00);
      vertex(30, -5, -20);
      vertex(30, -5, 20);
      vertex(30, 5, 20);
      vertex(30, 5, -20);

      //Y-
      fill(#ff00ff);
      vertex(-30, -5, -20);
      vertex(30, -5, -20);
      vertex(30, -5, 20);
      vertex(-30, -5, 20);

      //Y+
      fill(#00ffff);
      vertex(-30, 5, -20);
      vertex(30, 5, -20);
      vertex(30, 5, 20);
      vertex(-30, 5, 20);

      endShape();
    }
    Thread logicThread = new Thread(new Runnable() {
      public void run() {
        System.out.println(Thread.currentThread().getName() + " : the logicThread is running");

        //main Logic loop
        while (true) {


          countLogicCalls++;
      // Sensor no : 0
      if (ports[0].available() &gt; 6) {
      inBuffer1 = ports[0].readStringUntil('\r');
      }

            if (inBuffer1 != null){
            convert_raw_data_to_angles(inBuffer1,0); 
            convert_raw_data_to_quaternions(inBuffer1);
          }

          //------------
          //framelimiter
          int timeToWait = 1000/framerateLogic - (millis()-lastCallLogic); // set framerateLogic to -1 to not limit;
          if (timeToWait &gt; 1) {
            try {
              //sleep long enough so we aren't faster than the logicFPS
              Thread.currentThread().sleep( timeToWait );
            }
            catch ( InterruptedException e )
            {
              e.printStackTrace();
              Thread.currentThread().interrupt();
            }
          }
          /**
          example why we wait excactly: 1000/framerate - (millis-lastcall)

           framerate = 100 //framerate we want
           1000/framerate = 10 //time for one loop
           millis = 1952 //current time
           last call logic = 1949 //time when last logic loop finished

           how  long should the programm wait??

           millis-lastcall = 3 -&gt; the whole loop took 3ms

           1000/framerate - (millis-lastcall) = 7ms -&gt; we will have to wait 7ms to keep a framerate of 100

           */

          //remember when the last logic loop finished
          lastCallLogic = millis();


          //End of main logic loop
        }
      }
    }
    );


    void convert_raw_data_to_angles(String inBuffer, int i)
    {
        int[] num = int(split(inBuffer,' '));
        if(num.length &gt;= 9){
        // Heading(Yaw) angle
        yaw[i] = float(((num[3])&lt;&lt;8 | num[2])/16);    
        roll[i] = float(((num[5])&lt;&lt;8 | num[4])/16);
        pitch[i] = float(((num[7])&lt;&lt;8 | num[6])/16);
        if(pitch[i] &gt; 180.0F)
          pitch[i] = pitch[i] - 4096;
        if(roll[i] &gt; 90.0F)
          roll[i] = roll[i] - 4096;
       }
    }
    void convert_raw_data_to_quaternions(String inBuffer)
    {
       int[] num = int(split(inBuffer,' '));
        if(num.length &gt;= 9){
        // Heading(Yaw) angle
        q[0] = ((num[9])&lt;&lt;8 | num[8])/16384.000000F;    
        q[1] = ((num[11])&lt;&lt;8 | num[10])/16384.000000F;
        q[2] = ((num[13])&lt;&lt;8 | num[12])/16384.000000F;
        q[3] = ((num[15])&lt;&lt;8 | num[14])/16384.000000F;
        for (int i = 0; i &lt; 4; i++) if (q[i] &gt;= 2) q[i] = -4 + q[i];
       }
       // set our toxilibs quaternion to new data
       quat.set(q[0], q[1], q[2], q[3]);
    }
</code></pre>

<p>I have to plot the graph real time w.r.t to any two values/all. Please help me out in solving this.</p>

<p>Thanks in advance</p>
]]></description>
   </item>
   <item>
      <title>Creating multiple arrays from a txt file</title>
      <link>https://forum.processing.org/two/discussion/23770/creating-multiple-arrays-from-a-txt-file</link>
      <pubDate>Thu, 10 Aug 2017 15:16:00 +0000</pubDate>
      <dc:creator>CentricArts</dc:creator>
      <guid isPermaLink="false">23770@/two/discussions</guid>
      <description><![CDATA[<p>I'm currently trying to create a visual diagram of solar winds within processing, but I'm struggling on trying to structure it and I need help.</p>

<p>Using <a href="http://services.swpc.noaa.gov/text/ace-swepam.txt" target="_blank" rel="nofollow">http://services.swpc.noaa.gov/text/ace-swepam.txt</a> I need to collect proton density, bulk speed and ion temperature and create a visual diagram which I will get into once I've collected all 120 points of data (1 per minute over the course of 2 hours)</p>

<p>I've worked with txt files before because they're easier to determine and separate different values, but I would still struggle with removing certain values from a row of multiple values.</p>

<p><img src="https://i.gyazo.com/bc9dd983a2248bfeb1350d37fbd7893b.png" alt="" /></p>

<p>This was my original idea on how to do it, but doing it this way would require copying and pasting this 120 times and adjusting it along the way.</p>

<p>I want to do what I've done, but using i+ 120 times to get everything stored in a single array but I have no idea how.</p>
]]></description>
   </item>
   <item>
      <title>Plotting a graph in real time for infinite time</title>
      <link>https://forum.processing.org/two/discussion/20574/plotting-a-graph-in-real-time-for-infinite-time</link>
      <pubDate>Tue, 31 Jan 2017 12:27:55 +0000</pubDate>
      <dc:creator>hassan548</dc:creator>
      <guid isPermaLink="false">20574@/two/discussions</guid>
      <description><![CDATA[<p><img src="https://forum.processing.org/two/uploads/imageupload/067/0BRORY4Z7O5T.png" alt="graphpic" title="graphpic" /></p>

<p>Hi,
I am showing the IMU data through serial in real time.
Now the problem is that if  the values exceed the frame then i have to run the program again to further see the values.
how can i do something like it will show the graph until i stop the program.thanks</p>

<p>Here is my code</p>

<p>`import processing.serial.*;
import java.awt.datatransfer.*;
import java.awt.Toolkit;
import processing.opengl.*;
import saito.objloader.*;
import g4p_controls.*;</p>

<p>PGraphics rollG;
PGraphics rollG1;
PGraphics rollG2;
PGraphics pitchG;
PGraphics pitchG1;
PGraphics pitchG2;
PGraphics yawG;
PGraphics yawG1;
PGraphics yawG2;</p>

<p>float roll  = 0.0F;
float pitch = 0.0F;
float yaw   = 0.0F;
float temp  = 0.0F;
float alt   = 0.0F;
float prevR;
float prevR2;
float prevP;
float prevP2;
float prevY;
float prevY2;</p>

<p>float roll2  = 0.0F;
float pitch2 = 0.0F;
float yaw2   = 0.0F;</p>

<p>PFont f;</p>

<p>OBJModel model;</p>

<p>// Serial port state.
Serial       port;
final String serialConfigFile = "serialconfig.txt";
boolean      printSerial = false;</p>

<p>// UI controls.
GPanel    configPanel;
GDropList serialList;
GLabel    serialLabel;
GLabel    calLabel;
GCheckbox printSerialCheckbox;</p>

<p>void setup()
{
  size(800, 800, OPENGL);
  frameRate(30);
rollG=createGraphics(width,height/4);
rollG1=createGraphics(width,height/5);
rollG2=createGraphics(width,height/5);</p>

<p>pitchG=createGraphics(width,height/4);
pitchG1=createGraphics(width,height/5);
pitchG2=createGraphics(width,height/5);</p>

<p>yawG=createGraphics(width,height/4);
yawG1=createGraphics(width,height/4);
yawG2=createGraphics(width,height/4);</p>

<p>// Serial port setup.
  // Grab list of serial ports and choose one that was persisted earlier or default to the first port.
  int selectedPort = 0;
  String[] availablePorts = Serial.list();
  if (availablePorts == null) {
    println("ERROR: No serial ports available!");
    exit();
  }
  String[] serialConfig = loadStrings(serialConfigFile);
  if (serialConfig != null &amp;&amp; serialConfig.length &gt; 0) {
    String savedPort = serialConfig[0];
    // Check if saved port is in available ports.
    for (int i = 0; i &lt; availablePorts.length; ++i) {
      if (availablePorts[i].equals(savedPort)) {
        selectedPort = i;
      } 
    }
  }
  // Build serial config UI.
  configPanel = new GPanel(this, 10, 10, width-20, 90, "Configuration (click to hide/show)");
  serialLabel = new GLabel(this,  0, 20, 80, 25, "Serial port:");
  configPanel.addControl(serialLabel);
  serialList = new GDropList(this, 90, 20, 200, 200, 6);
  serialList.setItems(availablePorts, selectedPort);
  configPanel.addControl(serialList);
  calLabel = new GLabel(this, 300, 20, 350, 25, "Calibration: Sys=? Gyro=? Accel=? Mag=?");
  configPanel.addControl(calLabel); 
  printSerialCheckbox = new GCheckbox(this, 5, 50, 200, 20, "Print serial data");
  printSerialCheckbox.setSelected(printSerial);
  configPanel.addControl(printSerialCheckbox);
  // Set serial port.
  setSerialPort(serialList.getSelectedText());
   f = createFont("Arial",16,true);</p>

<p>}</p>

<p>void draw()
{</p>

<pre><code>background(0);
//drawRoll2();
 drawRoll1();
 drawPitch1();
 drawYaw1();
</code></pre>

<p>}</p>

<p>void drawRoll1() {
 rollG.beginDraw();
  for (int i = 0; i &lt;= width; i += 50) {
    rollG.fill(0, 255, 0);
    rollG.textFont(f,26); 
    rollG.text("Roll", 380, 20);
    //rollG.text(i/2, i-10, height-15);
    rollG.stroke(255);
    rollG.line(i, height, i, 0);
  }
  for (int j = 0; j &lt; height; j += 33) {
    rollG.fill(0, 255, 0);
    //rollG.text(6-j/(height/6), 0, j);
    rollG.stroke(255);
    rollG.line(0, j, width, j);
  }</p>

<p>rollG.endDraw();
   image(rollG,0,130);</p>

<p>rollG1.beginDraw();
   float plotroll = roll*5;
  rollG1.stroke(255, 0, 0);
  rollG1.line(frameCount-1, prevR, frameCount, plotroll);
  prevR = plotroll;</p>

<p>rollG1.endDraw();
   image(rollG1,0,160);</p>

<pre><code>rollG2.beginDraw();
</code></pre>

<p>float plotroll2 = roll2*5;
  rollG2.stroke(0, 255, 0);
  rollG2.line(frameCount-1, prevR2, frameCount, plotroll2);
  prevR2 = plotroll2;</p>

<p>rollG2.endDraw();
   image(rollG2,0,160);</p>

<p>}</p>

<p>void drawPitch1() {
 pitchG.beginDraw();
  for (int i = 0; i &lt;= width; i += 50) {
    pitchG.fill(0, 255, 0);
    pitchG.textFont(f,26); 
    pitchG.text("Pitch", 380, 20);
    //pitchG.text(i/2, i-10, height-15);
    pitchG.stroke(255);
    pitchG.line(i, height, i, 0);
  }
  for (int j = 0; j &lt; height; j += 33) {
    pitchG.fill(0, 255, 0);
    //pitchG.text(6-j/(height/6), 0, j);
    pitchG.stroke(255);
    pitchG.line(0, j, width, j);
  }</p>

<p>pitchG.endDraw();
   image(pitchG,0,350);</p>

<p>pitchG1.beginDraw();
   float plotpitch = pitch*5;
  pitchG1.stroke(255, 0, 0);
  pitchG1.line(frameCount-1, prevP, frameCount, plotpitch);
  prevP = plotpitch;</p>

<p>pitchG1.endDraw();
   image(pitchG1,0,360);</p>

<pre><code>pitchG2.beginDraw();
</code></pre>

<p>float plotpitch2 = pitch2*5;
  pitchG2.stroke(0, 255, 0);
  pitchG2.line(frameCount-1, prevP2, frameCount, plotpitch2);
  prevP2 = plotpitch2;</p>

<p>pitchG2.endDraw();
   image(pitchG2,0,360);</p>

<p>}</p>

<p>void drawYaw1() {
 yawG.beginDraw();
  for (int i = 0; i &lt;= width; i += 50) {
    yawG.fill(0, 255, 0);
     yawG.textFont(f,26); 
    yawG.text("Yaw", 380, 20);
    //yawG.text(i/2, i-10, height-15);
    yawG.stroke(255);
    yawG.line(i, height, i, 0);
  }
  for (int j = 0; j &lt; height; j += 33) {
    yawG.fill(0, 255, 0);
    //yawG.text(6-j/(height/6), 0, j);
    yawG.stroke(255);
    yawG.line(0, j, width, j);
  }</p>

<p>image(yawG,0,570);
  yawG.endDraw();</p>

<p>yawG1.beginDraw();
   float plotyaw = -1*yaw/2;</p>

<p>yawG1.stroke(255, 0, 0);
  yawG1.line(frameCount-1, prevY, frameCount, plotyaw);
  prevY = plotyaw;</p>

<p>image(yawG1,0,630);
   yawG1.endDraw();</p>

<pre><code>yawG2.beginDraw();
</code></pre>

<p>float plotyaw2 = -1*yaw2/2;
  yawG2.stroke(0, 255, 0);
  yawG2.line(frameCount-1, prevY2, frameCount, plotyaw2);
  prevY2 = plotyaw2;</p>

<p>image(yawG2,0,630);
  yawG2.endDraw();</p>

<p>}</p>

<p>void serialEvent(Serial p) 
{
  String incoming = p.readString();
  if (printSerial) {
    println(incoming);
  }</p>

<p>if ((incoming.length() &gt; 8))
  {
    String[] list = split(incoming, " ");
    if ( (list.length &gt; 0) &amp;&amp; (list[0].equals("Orientation:")) ) 
    {</p>

<pre><code>  roll  = float(list[1]); // Roll = Z
  pitch = float(list[2]); // Pitch = Y 
  yaw   = float(list[3]); // Yaw/Heading = X

}

 if ( (list.length &gt; 0) &amp;&amp; (list[0].equals("Orientation2:")) ) 
{

  roll2  = float(list[1]); // Roll = Z
  pitch2 = float(list[2]); // Pitch = Y 
  yaw2   = float(list[3]); // Yaw/Heading = X

}

if ( (list.length &gt; 0) &amp;&amp; (list[0].equals("Alt:")) ) 
{
  alt  = float(list[1]);
}
if ( (list.length &gt; 0) &amp;&amp; (list[0].equals("Temp:")) ) 
{
  temp  = float(list[1]);
}
if ( (list.length &gt; 0) &amp;&amp; (list[0].equals("Calibration:")) )
{
  int sysCal   = int(list[1]);
  int gyroCal  = int(list[2]);
  int accelCal = int(list[3]);
  int magCal   = int(list[4]);
  calLabel.setText("Calibration: Sys=" + sysCal + " Gyro=" + gyroCal + " Accel=" + accelCal + " Mag=" + magCal);
}
</code></pre>

<p>}
}</p>

<p>// Set serial port to desired value.
void setSerialPort(String portName) {
  // Close the port if it's currently open.
  if (port != null) {
    port.stop();
  }
  try {
    // Open port.
    port = new Serial(this, portName, 115200);
    port.bufferUntil('\n');
    // Persist port in configuration.
    saveStrings(serialConfigFile, new String[] { portName });
  }
  catch (RuntimeException ex) {
    // Swallow error if port can't be opened, keep port closed.
    port = null; 
  }
}</p>

<p>// UI event handlers</p>

<p>void handlePanelEvents(GPanel panel, GEvent event) {
  // Panel events, do nothing.
}</p>

<p>void handleDropListEvents(GDropList list, GEvent event) { 
  // Drop list events, check if new serial port is selected.
  if (list == serialList) {
    setSerialPort(serialList.getSelectedText()); 
  }
}</p>

<p>void handleToggleControlEvents(GToggleControl checkbox, GEvent event) { 
  // Checkbox toggle events, check if print events is toggled.
  if (checkbox == printSerialCheckbox) {
    printSerial = printSerialCheckbox.isSelected(); 
  }
}`</p>
]]></description>
   </item>
   <item>
      <title>Realtime plotting rate</title>
      <link>https://forum.processing.org/two/discussion/18619/realtime-plotting-rate</link>
      <pubDate>Wed, 19 Oct 2016 12:53:29 +0000</pubDate>
      <dc:creator>xytan97</dc:creator>
      <guid isPermaLink="false">18619@/two/discussions</guid>
      <description><![CDATA[<p>HI may i know if there is any solution to plot data at a faster rate? i am getting data from a sensor and would like to plot my data realtime.</p>

<p>Please provide me with any source code or ideas to counter my problem.Thank You</p>
]]></description>
   </item>
   <item>
      <title>Out of Control y Axis- ROLLING GRAPH</title>
      <link>https://forum.processing.org/two/discussion/17900/out-of-control-y-axis-rolling-graph</link>
      <pubDate>Fri, 19 Aug 2016 03:53:51 +0000</pubDate>
      <dc:creator>Chil_Polins</dc:creator>
      <guid isPermaLink="false">17900@/two/discussions</guid>
      <description><![CDATA[<p>Noobie here, I'm trying to take an input from an arduino over a usb and plot onto a graph. Everything is fine except I cant seem to map where the y begins and ends on my graph. I tried so many things but its stuck between 0 and about 400px. You'll see the box where the graph is suppose to occupy. I can't move/control the y axis. I drew out the issue in red on the attached image, please help!!</p>

<p>You'll see reference to multiple sensors, I am only trying to plot the sensor "moisture" for now.</p>

<pre><code>/This sketch is frankensteined from the SerialCall Response example with arduino and 
//this guy's sketch(code in description of video) - <a href="http://pastebin.com/kSrU3nVH" target="_blank" rel="nofollow">http://pastebin.com/kSrU3nVH</a>

import processing.serial.*;

int moisture;  //the only sensor I'm currently trying to plot 
float inByte;
int second; //sensors that ar![]()e not yet plotted but printed in the Console
int third;  // " "
int fourth; // " "

Serial myPort;                       // The serial port
int[] serialInArray = new int[4];    // Where we'll put what we receive
int serialCount = 0;                 // A count of how many bytes we receive
PFont  g_font;
boolean firstContact = false;        // Whether we've heard from the microcontroller

int[] yValues;
int w;

//SETUP
void setup() {
  size(1280, 720);  // Stage size

  g_font = loadFont("ArialMT-20.vlw");
  textFont(g_font, 20);

  w = 640; //width of our plot
  strokeWeight(1);
  smooth(); // or noSmooth();
  yValues = new int[w];

  println(Serial.list());
  String portName = Serial.list()[1];
  myPort = new Serial(this, portName, 9600);
}

void draw() { 
  String inString = myPort.readStringUntil('\n');

  if (inString != null) {
    inString = trim(inString);
    inByte = float(inString);

    moisture = int(map(inByte, 0, 255, 360, 25));
    //setting the boundry for the graph line, inside box EXCEPT IT DOESNT WORK
  }

  //This should be down here, but works inside the if statement.
  //moisture = int(map(inByte, 0, 255, 360, 25));

  //Background and box for graph
  background(55);
  rect(25, 25, 615, 335);
  fill(255);
  //LEGEND
  strokeWeight(1.5);
  stroke(255, 0, 0);     
  line(20, 420, 35, 420);
  stroke(0, 255, 0);     
  line(20, 440, 35, 440);
  stroke(0, 0, 255);     
  line(20, 460, 35, 460);
  stroke(255, 255, 0);   
  line(20, 480, 35, 480);

  fill(0, 0, 0);
  text("Moisture", 40, 430);
  text("Analog A1", 40, 450);
  text("Analog A2", 40, 470);
  text("Analog A3", 40, 490);

  //ACTUAL PLOTTED LINE
  for (int i = 1; i &lt; w; i++) {
    yValues[i-1] = yValues[i];
  }
  yValues[w-1] = moisture; 
  //}

  stroke(120, 200, 0);
  line(w, moisture, 0, moisture);
  strokeWeight(3);


  //This controls the horizontal "TICKER LINE"
  for (int i=1; i&lt;w; i++) {
    //stroke (rgb)
    stroke(220, 75, yValues[i]);
    //point folar x, float y
    point(i, yValues[i]);
    rect(0, 25, 50, 335);
    fill(255);
  }
}

void serialEvent(Serial myPort) {
  // read a byte from the serial port:
  int inByte = myPort.read();

  if (firstContact == false) {
    if (inByte == 'A') {
      myPort.clear();          // clear the serial port buffer
      firstContact = true;     // you've had first contact from the microcontroller
      myPort.write('A');       // ask for more
    }
  } else {
    // Add the latest byte from the serial port to array:
    serialInArray[serialCount] = inByte;
    serialCount++;

    // If we have 3 bytes:
    if (serialCount &gt; 3) {
      moisture = serialInArray[0];
      second = serialInArray[1];
      third = serialInArray[2];
      fourth = serialInArray[3];

      // print the values (for debugging purposes only):
      println(moisture + "\t" + second + "\t" + third + "\t" + fourth);

      // Send a capital A to request new sensor readings:
      myPort.write('A');
      // Reset serialCount:
      serialCount = 0;
    }
  }
}

/*ARDUINO UNO CODE
 int firstSensor = 0;    // first analog sensor
 int secondSensor = 0;   // second analog sensor
 int thirdSensor = 0;    // digital sensor
 int fourthSensor = 0; //turning this into a fluxuating value
 int inByte = 0;         // incoming serial byte

 void setup()
 {
 // start serial port at 9600 bps:
 Serial.begin(9600);


 pinMode(2, INPUT);   // digital sensor is on digital pin 2
 establishContact();  // send a byte to establish contact until receiver responds
 }

 void loop()

 {

 // if we get a valid byte, read analog ins:
 if (Serial.available() &gt; 0) {
 // get incoming byte:
 inByte = Serial.read();
 // read first analog input, divide by 4 to make the range 0-255:
 firstSensor = analogRead(A0);
 // delay 10ms to let the ADC recover:
 delay(10);
 // read second analog input, divide by 4 to make the range 0-255:
 secondSensor = analogRead(A1) / 4;
 // read  switch, map it to 0 or 255L
 thirdSensor = map(digitalRead(A2), 0, 1, 0, 255);
 // send sensor values:
 fourthSensor = analogRead(A3) / 4; //new sensor I added
 Serial.write(firstSensor);
 Serial.write(secondSensor);
 Serial.write(thirdSensor);
 Serial.write(fourthSensor);

 }
 }

 void establishContact() {
 while (Serial.available() &lt;= 0) {
 Serial.print('A');   // send a capital A
 delay(300);

 }
 }
 */![Screen Shot 2016-08-18 at 11.45.51 PM](<a href="https://forum.processing.org/two/uploads/imageupload/608/2KIEZIROU05C.jpg" target="_blank" rel="nofollow">https://forum.processing.org/two/uploads/imageupload/608/2KIEZIROU05C.jpg</a> "Screen Shot 2016-08-18 at 11.45.51 PM")
</code></pre>
]]></description>
   </item>
   <item>
      <title>Procesing with Jfree Chart</title>
      <link>https://forum.processing.org/two/discussion/13770/procesing-with-jfree-chart</link>
      <pubDate>Fri, 04 Dec 2015 06:12:50 +0000</pubDate>
      <dc:creator>roshani</dc:creator>
      <guid isPermaLink="false">13770@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I saw video on internet where they are receiving serial data &amp; plotting a graph using Java &amp; Jfree Chart.</p>

<p>Here is the link of video. Source code is open.</p>

<p><span class="VideoWrap"><span class="Video YouTube" id="youtube-cw31L_OwX3A"><span class="VideoPreview"><a href="http://youtube.com/watch?v=cw31L_OwX3A"><img src="http://img.youtube.com/vi/cw31L_OwX3A/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span></p>

<p>Here is the source code link.</p>

<p><a href="https://www.youtube.com/redirect?q=http%3A%2F%2Fwww.farrellf.com%2Farduino%2FSensorGraph.java&amp;redir_token=n6DitzxrIYtUbj3AGqFq9PO8z3J8MTQ0OTI5NTU0NEAxNDQ5MjA5MTQ0" target="_blank" rel="nofollow">https://www.youtube.com/redirect?q=http://www.farrellf.com/arduino/SensorGraph.java&amp;amp;redir_token=n6DitzxrIYtUbj3AGqFq9PO8z3J8MTQ0OTI5NTU0NEAxNDQ5MjA5MTQ0</a></p>

<p>Main beauty of graph is zoom in , zoom out, print &amp; save option, which you can see at the end of video.</p>

<p>I want to make same type chart with processing.</p>

<p>Can some one help me.</p>
]]></description>
   </item>
   <item>
      <title>receiving serial data and displaying it problems  with 3dr radio</title>
      <link>https://forum.processing.org/two/discussion/13398/receiving-serial-data-and-displaying-it-problems-with-3dr-radio</link>
      <pubDate>Wed, 04 Nov 2015 03:43:04 +0000</pubDate>
      <dc:creator>simon100</dc:creator>
      <guid isPermaLink="false">13398@/two/discussions</guid>
      <description><![CDATA[<p>Hi , I have just started using processing but have been using arduino for a couple of years  . I am using this code  to display csv data on my computer <a href="https://github.com/sebnil/RealtimePlotter" target="_blank" rel="nofollow">https://github.com/sebnil/RealtimePlotter</a>. When i receive the data throug the usb cable everything works as it should how ever when i receive it though the 3dr radio  gets messed up the strange thing though is that if i view the data from the 3dr radio in the serial monitor it reads perfect .  Its not complete rubbish like when the baud rate is wrong it just misses some characters , this is even when i send the data at only about 100 characters per second . Does any one have an idea whats going on here ?</p>
]]></description>
   </item>
   <item>
      <title>How to map large amounts of data points</title>
      <link>https://forum.processing.org/two/discussion/10600/how-to-map-large-amounts-of-data-points</link>
      <pubDate>Thu, 30 Apr 2015 21:13:25 +0000</pubDate>
      <dc:creator>7nicole3</dc:creator>
      <guid isPermaLink="false">10600@/two/discussions</guid>
      <description><![CDATA[<p>Im working on a project where I have to plot over 600,000 data points on to a map. Im using unfolding maps and the data points  based on latitude and longitude and are in a csv format. Because I have so many data points the program is either extremely slow or shuts down on me sometimes. I was wondering if there is any way that I can combine points from a location range so that the program only has to plot one point instead of plotting all in the range of lets say 5 miles? any suggestions??</p>
]]></description>
   </item>
   <item>
      <title>Having trouble with my array</title>
      <link>https://forum.processing.org/two/discussion/9883/having-trouble-with-my-array</link>
      <pubDate>Mon, 16 Mar 2015 16:02:15 +0000</pubDate>
      <dc:creator>Nadarchick</dc:creator>
      <guid isPermaLink="false">9883@/two/discussions</guid>
      <description><![CDATA[<p>hello! i am new to this whole forum thing, but i was wondering if i might humbly ask for some assistance? i am trying to configure a sketch that uses data plotting and my array is acting up. any/all help would be greatly appreciated. thank you so much.</p>

<pre lang="java">

//Information from: <a href="http://www.oceaneconomics.org/LMR/topTenResults.aspx?selRegions=GL&amp;selYears=2013&amp;selOut=display&amp;noepID=unknown" target="_blank" rel="nofollow">http://www.oceaneconomics.org/LMR/topTenResults.aspx?selRegions=GL&amp;selYears=2013&amp;selOut=display&amp;noepID=unknown</a>


XML FishValue;//The xml file is declared
//ArrayLists for data sets
ArrayList Fish fishes = new ArrayList Fish();
int numOfFish = 10; //number of fish
int [] position = new int [numOfFish]; // array for position of each fish's data
int [] fishValue = new int [numOfFish]; // array for fish values
String [] fishNames = new String [numOfFish];// array for fish names
PFont f;
PImage BG;

void setup() {
  size(640,480);
  colorMode(HSB,360,100,100,100);
 textAlign(CENTER);
  background(0);
  BG = loadImage("GreatLakes.jpg");
  
  //loads the xml file
 FishValue = loadXML("FishValue.xml");
 XML [] Fish = FishValue.getChildren("Fish"); //information is recognized with this function
  
  
 for (int i = 4; i &lt; numOfFish; i++){
   //the ValuePerFish given US dollar value of each fish
   //int ValuePerFish = 
   //the names of each fish
   fishNames[i] = Fish[i].getContent();
   //the spacing between fish data
   position [i] = (width/numOfFish)/2;
   position [i] += (i * (width/numOfFish)/1.5);
  }

 //elements
 for (int m = 0; m  position[0]-50 &amp;&amp; xMouse &lt; position[0]+50) {
      b.movement();
    b.display(70);
    //}
 
 //Points
  for (int i = 1; i &lt; numOfFish; i++) {
    //This causes the points to connect
    int m = i - 1;
    //The x and y positions
    float xPos1 = position[i]-(width/10)/1.2;
   float xPos2 = position[i];
   float yPos1 = height/1.1-FishValue[m]*4;
    float yPos2 = height/1.1-FishValue[i]*4;
    //The lines of the line graph
   //strokeWeight(2);
   //stroke(360,20);
    //line(xPos1, yPos1, xPos2, yPos2);
   //stroke(360,10);
    //line(xPos1, height/1.1, xPos2, height/1.1);
  }
  //The names for each fish
  for (int i = 0; i &lt; numOfFish; i++) {
    fill(170, 30, 90);
    text(fishNames[i], position[i], height/1.05);
 }
  //Value of each fish in US Dollars
  textSize(10);
  fill(360); //text color
  text("Value of each fish in U.S. Dollars", 100, 50);
}
 }
</pre>
]]></description>
   </item>
   </channel>
</rss>