x-values in stream plot option 'section' are not preserved to the figure properties

Dear Obspy-ers,

Short version of my problem (bug?): run demo

https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial_6.py

and hover with your mouse over this plot: the cursor shows the correct y-value, but no x-value. The longer description below explains when this becomes a problem.

thanks,
Kasper

Hi

Not sure wherein the root of the problem resides but it has been reported elsewhere before (e.g. ) If you are willing to hack the ObsPy code yourself, here’s a hack for you: add the following piece of code: in file: obspy/imaging/waveform.py at line: 1231 code: “������� ax.format_coord = lambda x, y: ‘x=%.1f y=%.1f’ % (x*self._tr_offsets.max()/1.e3, y)” In case you have a different version of obspy than I, locate the method “__sectInitPlot()” in the “WaveformPlotting()” class and insert the line of code just after the line that say’s “������� ax = self.fig.gca()” I’m quite sure the ObsPy team will look into this when they have the time and come up with a better solution (it may also be nice to add information about the amplitude of the nearest trace i.e. "x=… y =…� z=…) regP

Peter, thanks for the hint. I don’t mind changing the code as you suggested, but I had a look at that link you sent me, and this bug report is quite old and supposedly addressed years ago.

best,
kasper

Yup, its some three years old, didn't bother to look further once I've stumbled across a working solution.

Would be interesting though to understand why and when one needs to override the format_code() method. Haven't tested but probably you could also get do the same thing in your script and not having to edit the sourcecode, try retrieving the axes object of your figure, I think the proper line of code would be:

"axes = fig.AxesStack.as_list()"

and then looping over the axes instances (should be only one in your case) to override the format_code() method. But then again I have not tested this, and my experience with matlib is limited, so if you do test this or something similar, please report upon its success or not to aid others stumbling across the same problem. Thanks

regP