Saturday, April 4, 2009

A better line style method for Matlab plotting


I will be working with a student to create some seamless way to plot a high resolution data set using line markers to distinguish between data sets. Some reasons for why this is not so straightforward now is that if one wants to use Matlab's legend function to distinguish the data sets current methods make it difficult to get the desired effect.

To the right is an example that shows two aspects that we will try to improve upon: the more efficient use of the space in a figure and the use of plotting markers to distinguish lines without using a marker for each data point.

Notice that there is very little whitespace in the figure to the right. (There was still some unused space between the x axis label and the title of the axes below the label. This should be fixed.) This was achieved in a programmatic way. This is essential if one is generating a series of such plots for inclusion in a laboratory report.

Another aspect to observe in the figure is that though each data set has a high resolution each curve has around 5 or 6 plotting markers. This is to distinguish between the lines when one does not need to see where each data point is.

Matlab's latex interpreter is broken


When trying to use something like

title('$\int_0^1 f(x) \, dx $', 'interpreter', 'latex');

in (some versions of) Matlab on a Unix platform the output is garbled. The image to the left shows a zoom-in of the title of two plots using the above code: Within the image are two parts: the left is the result of executing the above code on a Windows machine while the left was generated by executing the above code on a Unix machine. I wish someone had a fix for this. Such capability would be really useful.

Here is a link to a post from 2008 that shows that this problem has not been taken care of

http://www.mathworks.de/matlabcentral/newsreader/view_thread/161183