Serial plotter very fast in adruino 2.1

With the sketch below, why are there so many points on the X scale between every Serial.println number ) ; ??

This makes the Serial Plotter almost useless for me.

Am i missing a setting ??

int number =0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin( 9600 );
  
}

void loop() {
  // put your main code here, to run repeatedly:
  if( number ) {
    number = 0;
  } else {
    number = 100 ;
  }
  Serial.println( number );
}
Serial.begin(115200);
1 Like

Try pausing the Serial plotter and you will see that not every value is printed but every value is plotted

1 Like

Looks like both the y-axis and x-axis is auto scaled (normalized). If so, that's actually a nice feature! I've been holding off on using 2.1, but i think its time to give it a run.

vroemm,

The Serial Plotter is plotting 0 and 100 alternately - exactly as you have asked it to.

What are you expecting/wanting to see?

I took it to mean that @vroemm was expecting to see every value printed on the x axis but as I illustrated that is not what happens

The X axis only shows a few values.
If the plot points on the x axis would be closer together you could see a lot more data in one go.

2 Likes

Hi @vroemm. The Arduino IDE developers are tracking this request here:

If you have a GitHub account, you can subscribe to that issue to get notifications of any new developments related to this subject.


The discussion linked above does contain a hack for changing the number of data points, but it is a fairly advanced endeavor and something that would need to be repeated every time you update to a new version of Arduino IDE.

1 Like

I consider the auto scaling of plot width a valuable feature because it automatically zooms in to full width for the available data, then it becomes a sliding -window. The interpolate (spline) option for connecting the data points is a really nice new feature.

As it stands now, the plot width auto scales to full width as the data fills to 50 samples, then the plotter becomes a sliding window.

Plotter

Perhaps an improvement would be to have the plot width auto scale to full width as the data fills to 500 samples (or a user set limit), then the sliding window activates.

I'll add a suggestion to the GitHub link provided. (thanks)

Same code, 100 samples shown on plotter using Arduino IDE 1.8.19 ...

1 Like

Yep, there is the problem, only 50 real data points on the x axis.
It feels good to be understood :slight_smile:

A user set limit, a user set limit, yes please :-))
I would go for the possibility to set the x axis to even more then the number of pixels on the x axis.
Then one pixel on the x axis could have more then one data point on the y axis.
Just in case it is useful some day :slight_smile:

Thank you very much..

The chart of this code is much more understandable on arduino 1.8.x compared to 2.x

float number =1;
bool up = true;

void setup() {
  // put your setup code here, to run once:
  Serial.begin( 115200 );
  
}

void loop() {
  // put your main code here, to run repeatedly:

  if( number > 100 ) up = false;
  if ( number < 1) up = true;

  if( up ) {
    number = number * 1.05;
  } else {
    number = number / 1.05;
  }

  Serial.println( number );
  delay(10);
}

Yes, this would be handy. It could be done now within your code (but not as convenient) ... just skip every nth data point. This works fine if you're plotting slow responding signals. like a thermal heater with pid control.

For example, below is an image where I've plot every 6th datapoint from a dataset of about 2000 readings taken at 1 reading per sec. Now the resulting plot fits within the 500 sample range (using IDE 1.8..19) and also makes the x value represent time (0-500 representing 0-5 minutes). This also represents 0-3000 samples. The "6X compressed" graph still looks OK ...

Your methode can be useful also.

On the other hand, if you do not skip any data points, but put them in one x axis point, then you still see all the data.

Could be useful in surprise situations.

Well, if you had 2000 data-points and only 500 pixels to display them, instead of skipping, could just average 4 readings at a time, every 4 reading average gets plotted.

How about this approach ?

The serial plot window has a x width number of pixels.
Use this number as the number of data points. ( Minus some room for the Y scale numbers ).

And add the user option to make the distance between data points 1,2,3,4,5,6,7,8,9 or 10 pixels on the x axis.
This way you can see each data point more independent.
And add the user option to place 1,2,3,4,5,6,7,8,9 or 10 data points on one X pixel.
To compress long processes and still see the data.

Simply use all pixels on the x axis for data points.
One pixel = one data point.
And add 10 times zoom in, 10 times zoom out.

Is there a better option ?

Ahh, OK. I think you're describing a scatter chart or scatter plot ...

Multiple data-points shown vertically (y value) for each x pixel. Data points are not connected.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.