## Plot data like MATLAB or PyLab

Jun 3, 2007 at 4:45pm

# Plot data like MATLAB or PyLab

Hi,
MATLAB and PyLab have some amazing commands such as plot() that will
make a nice plot of some data. I’m porting my work from these
environments into Max/MSP/Jitter to do live audio analysis rather
than to work with sound files. I was wondering if there is a Jitter
quivalent of plot()?

Let me exemplify:
I’ve created a matrix that contain 5 times 11 float32s. These are 5
functions that have generated 11 values each for the x-values 0 to
10. I would like to see these graphs on my screen using jit.window

Another example: I’ve got one function that creats a list of 11
floats. I want to put them in a matrix and visualize the change of
these values over time.

How can I plot both/either the 5 functions and/or the list of floats
over time? What are the most common way of doing this?

Cheers

Nik

#32246
Jun 3, 2007 at 8:18pm

Hi Wes,
thanks for the tip. I’ve tried googling on these and Tutorial as I
only can find jit.gl.sketch in the Jitter Tutorial that comes with
Jitter. Do you have any examples on how these objects have been used
to plot graphs? A link or example patch?

Sincerely yours

Nik

On Jun 3, 2007, at 6:56 PM, Wesley Smith wrote:

> Try using OpenGL. There’s jit.gl.graph, jit.gl.mesh, and
> jit.gl.sketch which could all do the job depending on your situation.
>
> wes
>
> On 6/3/07, Niklas Saers wrote:
>> Hi,
>> MATLAB and PyLab have some amazing commands such as plot() that will
>> make a nice plot of some data. I’m porting my work from these
>> environments into Max/MSP/Jitter to do live audio analysis rather
>> than to work with sound files. I was wondering if there is a Jitter
>> quivalent of plot()?
>>
>> Let me exemplify:
>> I’ve created a matrix that contain 5 times 11 float32s. These are 5
>> functions that have generated 11 values each for the x-values 0 to
>> 10. I would like to see these graphs on my screen using jit.window
>>
>> Another example: I’ve got one function that creats a list of 11
>> floats. I want to put them in a matrix and visualize the change of
>> these values over time.
>>
>> How can I plot both/either the 5 functions and/or the list of floats
>> over time? What are the most common way of doing this?
>>
>> Cheers
>>
>> Nik
>>

#105701
Jun 4, 2007 at 5:09am

Hi again Wes,
the helpfiles and experimented a little with them. The reason I ask
is that I don’t have the OpenGL skills to make this as my work has
mainly been revolving MSP and Java, and I need something to make a
plot. An example could be the brightness plot below. If there are
some examples on actual graphs, then I could use or modify them as a
starting point and gradually learn GL.

The jit.gl.graph help file uses jit.catch~ to capture audio. I
already have a list of floats, being coordinates in a graph. I would
like to draw a line between them much like is done in the brightness
graph attached. Based on the example I used jit.fill to fill a matrix
but ended up with nothing displayed and not really understanding what
I was doing. ;-) So yes, I did look at the help files before I went
to Google, but I’m not quite sure where to go from here.

Since Max so long has been attached to all kinds of MIDI and serial
devices to measure stuff I’m fairly sure I can’t be the first to want
to plot some data, so if your or anyone else on the list knows of any
examples or tutorials I could follow I would be very grateful for

Cheers

Nik

On Jun 3, 2007, at 11:07 PM, Wesley Smith wrote:

> have you tried looking at the help files? jit.gl.graph should be self
> explanatory, jit.gl.mesh just takes 3D coordinates which you can set
> to construct a graph from data.
>
> wes
>
> On 6/3/07, Niklas Saers wrote:
>
>> Hi Wes,
>> thanks for the tip. I’ve tried googling on these and Tutorial as I
>> only can find jit.gl.sketch in the Jitter Tutorial that comes with
>> Jitter. Do you have any examples on how these objects have been used
>> to plot graphs? A link or example patch?
>>
>> Sincerely yours
>>
>> Nik
>>
>> On Jun 3, 2007, at 6:56 PM, Wesley Smith wrote:
>>
>> > Try using OpenGL. There’s jit.gl.graph, jit.gl.mesh, and
>> > jit.gl.sketch which could all do the job depending on your
>> situation.
>> >
>> > wes
>> >
>> > On 6/3/07, Niklas Saers
wrote:
>> >> Hi,
>> >> MATLAB and PyLab have some amazing commands such as plot() that
>> will
>> >> make a nice plot of some data. I’m porting my work from these
>> >> environments into Max/MSP/Jitter to do live audio analysis rather
>> >> than to work with sound files. I was wondering if there is a
>> Jitter
>> >> quivalent of plot()?
>> >>
>> >> Let me exemplify:
>> >> I’ve created a matrix that contain 5 times 11 float32s. These
>> are 5
>> >> functions that have generated 11 values each for the x-values 0 to
>> >> 10. I would like to see these graphs on my screen using jit.window
>> >>
>> >> Another example: I’ve got one function that creats a list of 11
>> >> floats. I want to put them in a matrix and visualize the change of
>> >> these values over time.
>> >>
>> >> How can I plot both/either the 5 functions and/or the list of
>> floats
>> >> over time? What are the most common way of doing this?
>> >>
>> >> Cheers
>> >>
>> >> Nik
>> >>
>>
>>
>>
>

#105703
Jun 4, 2007 at 1:42pm

#105706
Jun 6, 2007 at 5:44pm

Dear Wes,
thank you very much for your example.

> Here’s what I would do:
> Use jit.expr to make x-coordinates for your plot and set your data as
> y coordinates with the z coordinate as 0. This is all in a 3 plane
> float32 matrix. Render it with jit.gl.mesh @draw_mode line_strips.

So, the x part is the |jit.matrix 3 float32 1000| that is filled into
|jit.expr @expr “snorm[0]“| where the jit.noise generates the y axis
data?

I tried to adapt your example to a list of 11 floats but I must have
misunderstood a bit as I only get a single line going upwards rather
than data on the x axis.

Just one more thing I didn’t understand from your patch: why is it
that when it is loaded the data is presented in the upper half of the
window, and when I press bang again the data is tilted?

Cheers

Nik

PS, I’ve attached the slightly modified version where I fill up a
matrix with 11 numbers in the first plane.

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 7 239 160 196617 jit.matrix theArray 3 float32 11;
#P newex 6 220 91 196617 jit.fill theArray 0;
#P message 6 201 187 196617 1. 4.5 7. 3.8 7. 4.5 1. 9. 15. 33.8 98.7;
#P newex 157 356 268 196617 jit.expr 3 float32 11 @expr “snorm[0]” “in
[0].p[0]” “0″;
#P newex 157 380 194 196617 jit.gl.mesh test @draw_mode line_strips;
#P newex 83 126 48 196617 loadbang;
#P button 83 150 15 0;
#P newex 157 265 64 196617 jit.op @op +;
#P newex 211 196 132 196617 jit.expr @expr “snorm[0]“;
#P newex 211 172 115 196617 jit.matrix 3 float32 11;
#P newex 83 172 107 196617 jit.noise 3 float32 11;
#P newex 157 333 137 196617 jit.matrix data 3 float32 11;
#N vpatcher 10 59 171 198;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 74 79 41 196617 s draw;
#P window linecount 1;
#P newex 50 50 58 196617 t b b erase;
#P inlet 50 30 15 0;
#P outlet 50 79 15 0;
#P connect 1 0 2 0;
#P fasten 2 2 0 0 103 73 55 73;
#P lcolor 13;
#P connect 2 0 0 0;
#P connect 2 1 3 0;
#P pop;
#P newobj 18 73 42 196617 p Draw;
#P message 112 73 70 196617 fullscreen \$1;
#N vpatcher 10 59 170 225;
#P window setfont “Sans Serif” 9.;
#P newex 50 72 38 196617 sel 27;
#P newex 50 50 40 196617 key;
#P outlet 50 94 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P pop;
#P newobj 112 33 33 196617 p Esc;
#P toggle 112 54 15 0;
#P newex 112 93 151 196617 jit.window test @depthbuffer 1;
#P newex 18 51 57 196617 qmetro 33;
#P toggle 18 31 15 0;
#P newex 18 94 86 196617 jit.gl.render test;
#P connect 17 0 18 0;
#P connect 18 0 19 0;
#P connect 19 0 12 1;
#P connect 11 0 12 0;
#P fasten 13 0 17 0 88 167 11 167;
#P connect 1 0 2 0;
#P connect 2 0 7 0;
#P connect 7 0 0 0;
#P connect 14 0 13 0;
#P connect 13 0 9 0;
#P connect 5 0 4 0;
#P connect 4 0 6 0;
#P connect 6 0 3 0;
#P connect 12 0 8 0;
#P connect 8 0 16 0;
#P connect 16 0 15 0;
#P fasten 13 0 10 0 88 168 216 168;
#P connect 10 0 11 0;
#P window clipboard copycount 20;

>
> wes
>
> On 6/3/07, Niklas Saers wrote:
>> Hi again Wes,
>> the helpfiles and experimented a little with them. The reason I ask
>> is that I don’t have the OpenGL skills to make this as my work has
>> mainly been revolving MSP and Java, and I need something to make a
>> plot. An example could be the brightness plot below. If there are
>> some examples on actual graphs, then I could use or modify them as a
>> starting point and gradually learn GL.
>>
>>
>>
>>
>> The jit.gl.graph help file uses jit.catch~ to capture audio. I
>> already have a list of floats, being coordinates in a graph. I would
>> like to draw a line between them much like is done in the brightness
>> graph attached. Based on the example I used jit.fill to fill a matrix
>> but ended up with nothing displayed and not really understanding what
>> I was doing. ;-) So yes, I did look at the help files before I went
>> to Google, but I’m not quite sure where to go from here.
>>
>> Since Max so long has been attached to all kinds of MIDI and serial
>> devices to measure stuff I’m fairly sure I can’t be the first to want
>> to plot some data, so if your or anyone else on the list knows of any
>> examples or tutorials I could follow I would be very grateful for
>>
>> Cheers
>>
>> Nik
>>
>> On Jun 3, 2007, at 11:07 PM, Wesley Smith wrote:
>>
>>
>> > have you tried looking at the help files? jit.gl.graph should
>> be self
>> > explanatory, jit.gl.mesh just takes 3D coordinates which you can
>> set
>> > to construct a graph from data.
>> >
>> > wes
>> >
>> > On 6/3/07, Niklas Saers
wrote:
>> >
>> >> Hi Wes,
>> >> thanks for the tip. I’ve tried googling on these and Tutorial as I
>> >> only can find jit.gl.sketch in the Jitter Tutorial that comes with
>> >> Jitter. Do you have any examples on how these objects have been
>> used
>> >> to plot graphs? A link or example patch?
>> >>
>> >> Sincerely yours
>> >>
>> >> Nik
>> >>
>> >> On Jun 3, 2007, at 6:56 PM, Wesley Smith wrote:
>> >>
>> >> > Try using OpenGL. There’s jit.gl.graph, jit.gl.mesh, and
>> >> > jit.gl.sketch which could all do the job depending on your
>> >> situation.
>> >> >
>> >> > wes
>> >> >
>> >> > On 6/3/07, Niklas Saers
wrote:
>> >> >> Hi,
>> >> >> MATLAB and PyLab have some amazing commands such as plot() that
>> >> will
>> >> >> make a nice plot of some data. I’m porting my work from these
>> >> >> environments into Max/MSP/Jitter to do live audio analysis
>> rather
>> >> >> than to work with sound files. I was wondering if there is a
>> >> Jitter
>> >> >> quivalent of plot()?
>> >> >>
>> >> >> Let me exemplify:
>> >> >> I’ve created a matrix that contain 5 times 11 float32s. These
>> >> are 5
>> >> >> functions that have generated 11 values each for the x-
>> values 0 to
>> >> >> 10. I would like to see these graphs on my screen using
>> jit.window
>> >> >>
>> >> >> Another example: I’ve got one function that creats a list of 11
>> >> >> floats. I want to put them in a matrix and visualize the
>> change of
>> >> >> these values over time.
>> >> >>
>> >> >> How can I plot both/either the 5 functions and/or the list of
>> >> floats
>> >> >> over time? What are the most common way of doing this?
>> >> >>
>> >> >> Cheers
>> >> >>
>> >> >> Nik
>> >> >>
>> >>
>> >>
>> >>
>> >
>>
>>
>>
>>
>>
>>
>>

#105707
Jun 6, 2007 at 6:07pm

#105708
Jun 6, 2007 at 6:50pm

Hello Niklas,
Your patch is close, but it is slightly redundant. See the attached
patch for a more clarified version.

Also, the numbers you are packing into the matrix are not normalized to
a (-1 , 1) range, so the points that are plotted will end up outside of
the viewable area.

For your purposes, you might find jit.gl.sketch to be the more useful
interface, as it provides various drawing commands similar to jit.lcd.
For an example of using jit.gl.sketch to plot parametric data, check out
Jitter Recipe 23: ElapseGraph

http://www.cycling74.com/story/2006/2/14/161736/108

Sorry if this confuses more than it elucidates.

Andrew B.

#105709
Jun 6, 2007 at 8:49pm

Sorry, forgot the patch:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 67 350 68 196617 jit.normalize;
#P newex 67 299 160 196617 jit.matrix theArray 1 float32 11;
#P newex 66 280 91 196617 jit.fill theArray 0;
#P message 66 261 187 196617 1. 4.5 7. 3.8 7. 4.5 1. 9. 15. 33.8 98.7;
#P newex 67 395 268 196617 jit.expr 3 float32 11 @expr “snorm[0]“
“in[0].p[0]” “0″;
#P newex 67 419 189 196617 jit.gl.mesh test @draw_mode line_strip;
#P newex 143 186 48 196617 loadbang;
#P button 143 210 15 0;
#P newex 67 372 137 196617 jit.matrix data 3 float32 11;
#N vpatcher 10 59 171 198;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 74 79 41 196617 s draw;
#P window linecount 1;
#P newex 50 50 58 196617 t b b erase;
#P inlet 50 30 15 0;
#P outlet 50 79 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P fasten 2 2 0 0 103 73 55 73;
#P lcolor 13;
#P connect 2 1 3 0;
#P pop;
#P newobj 78 133 42 196617 p Draw;
#P message 172 133 70 196617 fullscreen \$1;
#N vpatcher 10 59 170 225;
#P window setfont “Sans Serif” 9.;
#P newex 50 72 38 196617 sel 27;
#P newex 50 50 40 196617 key;
#P outlet 50 94 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P pop;
#P newobj 172 93 33 196617 p Esc;
#P toggle 172 114 15 0;
#P newex 172 153 151 196617 jit.window test @depthbuffer 1;
#P newex 78 111 57 196617 qmetro 33;
#P toggle 78 91 15 0;
#P newex 78 154 86 196617 jit.gl.render test;
#P connect 14 0 15 0;
#P connect 15 0 16 0;
#P connect 16 0 8 0;
#P connect 12 0 11 0;
#P fasten 9 0 13 0 148 227 71 227;
#P connect 8 0 12 0;
#P connect 6 0 3 0;
#P connect 4 0 6 0;
#P connect 5 0 4 0;
#P connect 10 0 9 0;
#P connect 7 0 0 0;
#P connect 2 0 7 0;
#P connect 1 0 2 0;
#P connect 13 0 14 0;
#P window clipboard copycount 17;

#105710
Jun 7, 2007 at 8:16am

Hi Anthony,
thank you very much for the patch.

> Also, the numbers you are packing into the matrix are not
> normalized to
> a (-1 , 1) range, so the points that are plotted will end up
> outside of
> the viewable area.

Aha, that makes good sense. :-)

> For your purposes, you might find jit.gl.sketch to be the more useful
> interface, as it provides various drawing commands similar to jit.lcd.
> For an example of using jit.gl.sketch to plot parametric data,
> check out
> Jitter Recipe 23: ElapseGraph

Thank you very much, I’ll check it out. :-)

> Sorry if this confuses more than it elucidates.

Not at all, I’m very grateful for what you guys have taught me. :-)
My initial shock that there was no normal graph-plotting tool is
over, and this looks like it’s going to be fine. :-) Very interesting
to see the different options. :-)

Cheers

Nik

#105711

You must be logged in to reply to this topic.