better way to visualize profile data

I have data from a sensor that performs vertical profiles in the water (about 8 an hour) taking measurements on the order of a second. To visualize the profile data, I have been plotting time on the x and depth on the y and then coloring the data points with the actual variable being measured using the following code:
scatter(time,depth,3,variable,'filled').
Because of the high resolution of data points, the color is pretty much continuous once you plot about a day or more. However, using the colored scatter plot is VERY slow and it takes a full minute to plot about 12 hours worth of data. I would like to plot longer time intervals (typically a day or two, but sometimes up to a month) but this just isn't possible the way I am going about it now.
Does anyone have a suggestion for an alternate approach to visualizing this data?
I am fairly new to matlab and self-taught so please keep that in mind when responding.
Your help will be truly appreciated!! Thanks, Sarah

1 Commento

Thanks to those of you who have made suggestions. I still haven't resolved the issue, but have gotten closer to the source of the problem I think. I made a stripped down version of the GUI that I am using and discovered that the time delay with the profile plot has more to do with the fact that I am generating two plots (on two different axes) in my GUI. If I plot the colored scatter plot alone, it only takes about 2-3 seconds for a day's worth of data, but if I also try to plot a simple time series first on the other axes (using the plot function), it slows down to over a minute. Either plot alone generates rather quickly, but both together just bog down. I've posted the simple testGUI as well as the test dataset in dropbox at links at the end of this post. To test it, I simply select the pressure data and the color data in the e popupmenus and then press plot. If I comment out either of the plots, the remaining single plot generates quickly. Again, I am grateful for any help here. Walter Roberston’s suggestion of painting into an array and then imaging the array sounded promising, but I haven’t had luck figuring out how to do this. I don’t need to interact with the data in the scatter plot, only the simple time series plot.
Thanks again! Sarah
The dropbox links are:
Workspace data: http://dl.dropbox.com/u/53535639/testGUI/testGUI_data.mat
GUI figure: http://dl.dropbox.com/u/53535639/testGUI/testGUI.fig
GUI code: http://dl.dropbox.com/u/53535639/testGUI/testGUIcode.docx (I needed to copy it into word because the *.m file was not sharing correctly

Accedi per commentare.

Risposte (4)

If the data are pretty smooth, you could plot only every 10th or 100th value:
>> scatter(time(1:10:end),depth(1:10:end), ...)
Seems strange that it is so slow, though. How many points total are you plotting? Are you sure it is the plotting that is slow, as opposed to processing?

4 Commenti

12 hours times 60 minutes per hour times 60 seconds per minute is 43200 time points. If the "about 8 an hour" means 8 samples per second, that would be more than 345000 points per graph.
Each circle is drawn as an individual patch object. That's a *lot* of graphics objects for MATLAB, which is never happy with lots and lots of handles.
I had been thinking, "a million points will plot in the blink of an eye for me". I was failing to appreciate that each was a separate object in this case. Lots, indeed.
Sarah
Sarah il 15 Dic 2011
Actually, I am plotting within a GUI that I've built to loop through datasets. I just realized that the data plot much more quickly outside the GUI than within (5 seconds for 2 days worth of data vs. 60 seconds for 12 hours worth). Any ideas why this would be the case?
That does sound odd, Sarah.

Accedi per commentare.

Sean de Wolski
Sean de Wolski il 15 Dic 2011

0 voti

Look into using mesh with x/y axes for time/depth and height instead of color. Provide a small set of sample data and we can help more.

3 Commenti

Sarah
Sarah il 15 Dic 2011
That was an approach that seemed to make sense to me, but never having done this I couldn't make it work. I don't see a place to attach data (this is my first time posting a question here) but would be happy to provide some data.
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
Sarah
Sarah il 15 Dic 2011
Thanks. Here is a link to 2 day's worth of data:
http://dl.dropbox.com/u/53535639/exampleData.mat
I should note that depth is originally in a slightly different time-step and has been interpolated to the variable time-step.
Also, I just replied to 'the cyclist' with respect to the time the plot is taking. I am plotting it within a GUI that I've created to loop through data. I've noticed that it is MUCH slower inside the GUI than when I graph it outside of the GUI.

Accedi per commentare.

Walter Roberson
Walter Roberson il 15 Dic 2011

0 voti

Have you considered "painting" in to an array and then image()'ing the array? That would be much less work on the graphics engine. You would lose the ability to use the data cursor on each individual point, but perhaps that would be an acceptable tradeoff for you.

1 Commento

Sarah
Sarah il 15 Dic 2011
I tried to a little homework on what you meant by "painting" in, but came up short. Is there a reference you could direct me to?
Since all I need is to just view the picture, not being able to use the data cursor would be fine. Thanks, Sarah

Accedi per commentare.

Matlab cannot handle that many handle graphic objects efficiently. SCATTER creates one handle for each point. The following change to your code makes the response fast enough.
% make profile plot
axes(handles.axes1);
... scatter(colorTime,pressureData,3,colorData,'filled');
plot(colorTime,pressureData,'.');
However, that is not what you asked for. One way to make a plot similar to yours is as follows.
You can only distinguish say 64 colors. Create one line object for each color. Split your time series into 64 time series according to the value of the variable. Assign the appropriate color to each line. Use the functions LINE and SET.
It is doable and the code will be fast.

4 Commenti

Thanks, This sounds like a good approach - I will give it a try. As far as setting the colors, is there a default way to define the 64 colors through the spectrum?
There is the problem that it is plotting a line rather than points and so whatever lines are plotted last are 'on top' and the line between points will be colored over the data below leading to an incorrect image
There is no default way to handle 64 colors. The line object doesn't use colormap. I would set the line colors with RGB vectors. However, you can make a suitable colormap with the GUI, colormapeditor. Store that in a variable, my_line_colors = colormap; and ...., set( line_handle(jj), 'Color', my_line_color( jj, : ) ).
------
To plot points: set( line_handle(jj), 'LineStyle', 'none' )and look up line properties in the documentation. There are a handfull properties to set 'Marker', 'MarkerSize', etc.
There is a better way to set the colors. The property, ColorOrder, of axes takes a m-by-3 matrix of RGB values. That's a colormap. Thus, set( 0, 'DefaultAxesColorOrder', my_line_colors )

Accedi per commentare.

Categorie

Tag

Richiesto:

il 15 Dic 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by