Skip to content

Commit

Permalink
Attempt to add inset plots
Browse files Browse the repository at this point in the history
  • Loading branch information
mandli committed Jul 23, 2013
1 parent 8661028 commit 62f489d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
37 changes: 34 additions & 3 deletions 1d/setplot_shelf.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ def fill_items(plotaxes):
plotitem.color = 'k'
plotitem.plotstyle = plot.surface_linestyle
plotitem.show = True



# ========================================================================
# Full Depths
# ========================================================================
Expand Down Expand Up @@ -210,12 +211,42 @@ def momentum_axes(cd):
mpl.title("Layer Momenta at t = %4.1f s" % cd.t)

mpl.legend(['Top Layer Momentum','Bottom Layer Momentum'],loc=4)


def inset_momentum_axes(cd):
r"""This does not refresh correctly..."""
fig = mpl.figure(cd.plotfigure.figno)
axes = fig.add_subplot(111)

# Plot main figure
axes.plot(cd.x, hu_1(cd), 'b-')
axes.plot(cd.x, hu_2(cd), 'k--')
axes.set_xlim(xlimits)
axes.set_ylim(ylimits_momentum)
momentum_axes(cd)

# Create inset plot
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
from mpl_toolkits.axes_grid1.inset_locator import mark_inset
inset_axes = zoomed_inset_axes(axes, 0.5, loc=3)
inset_axes.plot(cd.x, hu_1(cd), 'b-')
inset_axes.plot(cd.x, hu_2(cd), 'k--')
inset_axes.set_xticklabels([])
inset_axes.set_yticklabels([])
x_zoom = [-120e3,-30e3]
y_zoom = [-10,10]
inset_axes.set_xlim(x_zoom)
inset_axes.set_ylim(y_zoom)
mark_inset(axes, inset_axes, loc1=2, loc2=4, fc='none', ec="0.5")
# mpl.ion()
mpl.draw()
# mpl.show()


plotaxes = plotfigure.new_plotaxes()
plotaxes.title = "Momentum"
plotaxes.xlimits = xlimits
plotaxes.ylimits = ylimits_momentum
plotaxes.afteraxes = momentum_axes
plotaxes.afteraxes = inset_momentum_axes

# Top layer
plotitem = plotaxes.new_plotitem(plot_type='1d')
Expand Down
11 changes: 7 additions & 4 deletions 1d/shelf.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ def jump_shelf(num_cells,eigen_method,**kargs):
controller.solver = solver

# Output parameters
controller.output_style = 1
controller.tfinal = 7200.0
controller.num_output_times = 300
# controller.output_style = 1
# controller.tfinal = 7200.0
# controller.num_output_times = 300
controller.output_style = 2
controller.out_times = [0.0,720.0,2400.0,4800.0,7200.0]
controller.write_aux_init = True
controller.outdir = outdir
controller.write_aux = True
Expand Down Expand Up @@ -243,6 +245,7 @@ def sloped_shelf(num_cells,eigen_method,**kargs):
controller.output_style = 1
controller.tfinal = 7200.0
controller.num_output_times = 300

controller.write_aux_init = True
controller.outdir = outdir
controller.write_aux = True
Expand Down Expand Up @@ -276,6 +279,6 @@ def sloped_shelf(num_cells,eigen_method,**kargs):
eig_methods = [2]

for method in eig_methods:
jump_shelf(2000,method,iplot=False,htmlplot=True)
jump_shelf(2000,method,iplot=True,htmlplot=False)
# for method in eig_methods:
# sloped_shelf(2000,method,iplot=False,htmlplot=True)

0 comments on commit 62f489d

Please sign in to comment.