Skip to content

Commit

Permalink
tweak multichannel plot
Browse files Browse the repository at this point in the history
  • Loading branch information
megies committed Sep 2, 2013
1 parent 0fba185 commit f08ecee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
32 changes: 26 additions & 6 deletions seedlink_plotter/seedlink_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import matplotlib
# Set the backend for matplotlib.
matplotlib.use("TkAgg")
matplotlib.rc('figure.subplot', hspace=0)
matplotlib.rc('font', family="monospace")

from obspy.core import Stream
import Tkinter
Expand All @@ -11,6 +13,7 @@
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
from matplotlib.ticker import MaxNLocator
from matplotlib.patheffects import withStroke
import matplotlib.pyplot as plt
from obspy.core import UTCDateTime
from obspy.core.event import Catalog
Expand Down Expand Up @@ -41,7 +44,6 @@ def __init__(self, stream=None, events=None, myargs=None, lock=None, multichanne

# main figure
self.figure = Figure()
self.figure.subplots_adjust(hspace=0)
canvas = FigureCanvasTkAgg(self.figure, master=self)

canvas.show()
Expand Down Expand Up @@ -123,11 +125,29 @@ def singlechannel_plot(self, stream):
def multichannel_plot(self, stream):
fig = self.figure
stream.plot(fig=fig, method="fast", draw=False, equal_scale=False,
size=(self.args.x_size, self.args.y_size))
for ax in fig.axes:
if ax is not fig.axes[-1]:
plt.setp(ax.get_xticklabels(), visible=False)
locator = MaxNLocator(4)
size=(self.args.x_size, self.args.y_size), title="")
fig.subplots_adjust(left=0, right=1, top=1, bottom=0)
bbox = dict(boxstyle="round", fc="w", alpha=0.8)
path_effects = [withStroke(linewidth=4, foreground="w")]
pad = 10
for tr, ax in zip(stream, fig.axes):
ax.set_title("")
ax.text(0.1, 0.9, tr.id, va="top", ha="left",
transform=ax.transAxes, bbox=bbox, size="xx-large")
xlabels = ax.get_xticklabels()
ylabels = ax.get_yticklabels()
plt.setp(ylabels, ha="left", path_effects=path_effects)
ax.yaxis.set_tick_params(pad=-pad)
# treatment for bottom axes:
if ax is fig.axes[-1]:
plt.setp(xlabels, va="bottom", size="x-large", bbox=bbox)
plt.setp(xlabels[:1], ha="left")
plt.setp(xlabels[-1:], ha="right")
ax.xaxis.set_tick_params(pad=-pad)
# all other axes
else:
plt.setp(xlabels, visible=False)
locator = MaxNLocator(nbins=4, prune="both")
ax.yaxis.set_major_locator(locator)
ax.yaxis.grid(False)
ax.grid(True, axis="x")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
INSTALL_REQUIRES = [
'numpy',
'scipy',
'matplotlib',
'matplotlib>=1.3.0',
'obspy']

setup(
Expand Down

4 comments on commit f08ecee

@sbonaime
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@megies Do you think
matplotlib>=1.3.0
could be changed to
matplotlib>=1.1.1
matplotlib 1.1.1 is the last stable version on Debian and Ubuntu. Thus it is not very easy to install seedlink_plotter for some users.

@megies
Copy link
Collaborator Author

@megies megies commented on f08ecee Mar 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. I can't find the reason for requesting 1.3.0 right now.. did you try and run it on 1.1.1 (all 2-3 different options single/multistation etc.)? If it runs.. sure. Any version that runs the code is fine.

@sbonaime
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested with 1.1.1 without errors. So I lowered the requirement for matplotlib.

@megies
Copy link
Collaborator Author

@megies megies commented on f08ecee Mar 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, good to hear it works on 1.1.1 also!

Please sign in to comment.