g2e / seizmo

passive(ly maintained) seismology toolbox for Matlab & GNU Octave
65 stars 55 forks source link

Error when plotting moment tensors Matlab 8.5.0.197613 (R2015a) Linux #14

Open Toeplitz opened 7 years ago

Toeplitz commented 7 years ago

Plotting of moment tensors with plotmt() fails with the following error:

For example:

plotmt(1:6,zeros(1,6),elementary_mt(1:6)); Warning: Ignoring the 'v6' argument to CONTOURF. This will become an error in a future release. In usev6plotapiHGUsingMATLABClasses>warnv6args (line 77) In usev6plotapiHGUsingMATLABClasses (line 40) In parseplotapi (line 11) In contourf (line 48) In plotmt (line 185) Error using matlab.graphics.chart.primitive.Contour/get There is no cdata property on the Contour class.

Error in plotmt (line 197) cdata=get(h{i,1},'cdata');

g2e commented 7 years ago

Thanks for pointing this out. I don't have a recent copy of Matlab available right now to look into this but I'll see if I can find one. As a rather poor workaround in a pinch, plotmt has a second approach using surf that is commented out in the code of plotmt.m. Just uncomment the blocks of code that say "for surf" and comment the blocks that say "for contour". Unfortunately the beachballs do not look as good - setting the "sample" option to 1 (from the default of 5) helps but this has a high cost in terms of speed & memory (which is why I hid this method).

Toeplitz commented 7 years ago

Thanks, for surf seems to be working.

Toeplitz commented 7 years ago

I have encountered another related issue. When saving high quality figures based on the moment tensors plots using matlab print command it crashes matlab because of the large amount of data in the figures. Maybe this is better for the contourf implementation?

g2e commented 7 years ago

I have a reworked plotmt version that still isn't there for Matlab 2014b+...see here for some details to the undocumented contour properties in 2014b+: http://undocumentedmatlab.com/blog/customizing-contour-plots Unfortunately I can't see how to find the contour level to which a "faceprim" corresponds - I don't have a new version of Matlab to look deeper though. From the comments on that page this appears to be a common unanswered question and from this relevant fileexchange repo's readme: https://github.com/kakearney/contourfcmap-pkg there appears to be a host of other issues with contouring & printing in 2014b+. Basically that person ended up writing their own contouring algorithm. Add on the 10x-100x slowdown in matlab graphics with 2014b+ (plus the enormous increase in .eps files) as mentioned here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/337755 and I think the only way forward for the train wreck that is 2014b+ is to manually draw patches for the moment tensors by computing the analytic solution as done here: http://www.mopad.org/

Gonna take some time to get that implemented into plotmt though. I did have a start at it a couple years ago but I didn't quite understand the algorithm.