phyphox Forums
How to plot two channels or more on the same graph? - Printable Version

+- phyphox Forums (https://phyphox.org/forums)
+-- Forum: Discussion (https://phyphox.org/forums/forumdisplay.php?fid=1)
+--- Forum: General (https://phyphox.org/forums/forumdisplay.php?fid=3)
+--- Thread: How to plot two channels or more on the same graph? (/showthread.php?tid=1684)



How to plot two channels or more on the same graph? - John - 01-30-2023

Hi

I am trying to plot 2 channels or more on the same graph with the x-axis as the time, y-axis for two channels:
1) raw data
2) filtered data

I wish to plot (1) and (2) on the same graph to illustrate effect of filtering.

My first attempt is to do :

Code:
firstGraph.setChannel(0,1);
firstGraph.setChannel(0,2); //there is no addChannel(0,2)...
....
PhyphoxBLE::write(raw, filtered_data);

But the code above will plot only one curve.

Any idea?

John


RE: How to plot two channels or more on the same graph? - Sebastian Staacks - 01-30-2023

setChannel simply sets the configuration and the second call replaces the previous setting. It is not possible to plot multiple curves in the same graph with the current version of the Arduino library. You either have to create a XML file with the experiment definition manually or wait for the next version, which will allow this.

In fact, the next version is already finished, but it is not compatible with the current phyphox release, so multiple curves should become available as soon as we release the next phyphox version - which should not be too long...


RE: How to plot two channels or more on the same graph? - John - 02-01-2023

(01-30-2023, 11:43 AM)Sebastian Staacks Wrote: setChannel simply sets the configuration and the second call replaces the previous setting. It is not possible to plot multiple curves in the same graph with the current version of the Arduino library. You either have to create a XML file with the experiment definition manually or wait for the next version, which will allow this.

In fact, the next version is already finished, but it is not compatible with the current phyphox release, so multiple curves should become available as soon as we release the next phyphox version - which should not be too long...

Hi Sebastian

Thank you. In my case I believe the "proper way" to do it is to add a new view as "Multi" just like the Acceleration with g experiment. I can do it with Phyphox editor. 
In Input Block, I would set a new input type as "Bluetooth". My BLE will send data of raw + filtered to Phyphox.

Configuration of multiple curves on the same graph is done in the Analysis tab of the Editor, wiring output buffers of raw and filtered data from the BLE node to the Multi-graph.

I will test it.

John


RE: How to plot two channels or more on the same graph? - Jens Noriʇzsɔɥ - 02-03-2023

Often, it makes sense to start right from an existing experiment (sources: https://github.com/phyphox/phyphox-experiments), replace the internal by bluetooth sensors, and delete anything you do not need. Smile


RE: How to plot two channels or more on the same graph? - John - 02-05-2023

(02-03-2023, 03:35 PM)Jens Noritzsch Wrote: Often, it makes sense to start right from an existing experiment (sources: https://github.com/phyphox/phyphox-experiments), replace the internal by bluetooth sensors, and delete anything you do not need. Smile

Thanks a lot.

I tried to edit the experiment "Acceleration with g" by loading it from "Load experiment" button in editor. Not changing anything yet. I loaded the experiment via QR code and found all 4 waveforms in MULTI of the same color-orange. This is different from the built-in experiment on smarphone under Raw Sensors>Acceleration with g in which I can see different colors.

The section of MULTI is extracted below:
Code:
        <view label="Multi">
            <graph editor:uuid="160" label="Acceleration" aspectRatio="2.5" style="lines" lineWidth="1" color="ff7e22" partialUpdate="true" history="1" labelX="t" labelY="a" labelZ="" unitX="s" unitY="m/s²" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">acc_time</input>
                <input axis="y">accX</input>
                <input axis="x">acc_time</input>
                <input axis="y">accY</input>
                <input axis="x">acc_time</input>
                <input axis="y">accZ</input>
                <input axis="x">acc_time</input>
                <input axis="y">acc</input>
            </graph>
            <value editor:uuid="161" label="Accelerometer x" size="2" precision="2" scientific="false" unit="m/s²" factor="1" color="green">
                <input>accX</input>
            </value>
            <value editor:uuid="162" label="Accelerometer y" size="2" precision="2" scientific="false" unit="m/s²" factor="1" color="blue">
                <input>accY</input>
            </value>
            <value editor:uuid="163" label="Accelerometer z" size="2" precision="2" scientific="false" unit="m/s²" factor="1" color="yellow">
                <input>accZ</input>
            </value>
            <value editor:uuid="164" label="Absolute acceleration" size="2" precision="2" scientific="false" unit="m/s²" factor="1" color="white">
                <input>acc</input>
            </value>
        </view>

This section supposed to display 4 waves of different color, right? When I load this experiment to my phone, all four waveforms of orange (see photo attached). Why is that?

The complete phyphox file is also included for reference.

John


RE: How to plot two channels or more on the same graph? - Jens Noriʇzsɔɥ - 02-06-2023

The editor does not support the full feature set of current phyphox. Your observation is at least sort-of documented on the welcome screen “[…]Note: While there have been many changes to the editor, not all new features of phyphox work in the editor like named colors or multi-data plots with individual colors.[…]”. Sad

We are working on a new blockly-based editor that hopefully can keep the pace of phyphox development then. If you need these features, then you need to resort to a standard text editor and directly edit the XML files.