[plotter] add embeded mode
This commit is contained in:
+22
-14
@@ -29,6 +29,7 @@ import datetime
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
from moviepy.video.io.ImageSequenceClip import ImageSequenceClip
|
||||
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
|
||||
|
||||
import pspec_read
|
||||
from baseprocessor import Rule, BaseProcessor
|
||||
@@ -568,7 +569,6 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
center_space=False,
|
||||
cmap="plasma",
|
||||
norm="log",
|
||||
put_cbar=True,
|
||||
transform=None,
|
||||
vmin=None,
|
||||
vmax=None,
|
||||
@@ -576,19 +576,23 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
scalebar_size=1,
|
||||
axes=True,
|
||||
colorbar=True,
|
||||
tight_cb=False,
|
||||
embeded=False,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
Plot data on a map
|
||||
"""
|
||||
|
||||
ax = plt.gca()
|
||||
ax_h = self._axes_h[ax_los]
|
||||
ax_v = self._axes_v[ax_los]
|
||||
|
||||
im_extent = np.array(self.save.root.maps._v_attrs.im_extent)
|
||||
unit_length = self.save.root._v_attrs["unit_length"]
|
||||
|
||||
if embeded:
|
||||
axes = False
|
||||
scalebar = True
|
||||
|
||||
if center_space:
|
||||
center = self.save.root.maps._v_attrs.center
|
||||
center_h = center[self._ax_nb[ax_h]]
|
||||
@@ -652,16 +656,14 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
plt.yticks([])
|
||||
|
||||
if colorbar:
|
||||
if tight_cb:
|
||||
ax = plt.gca()
|
||||
fig = plt.gcf()
|
||||
cax = fig.add_axes([
|
||||
ax.get_position().x1,
|
||||
ax.get_position().y0,
|
||||
0.03,
|
||||
ax.get_position().height
|
||||
])
|
||||
cbar = plt.colorbar(cax=cax)
|
||||
if embeded:
|
||||
cbaxes = inset_axes(ax, width="10%", height="100%", loc="right", borderpad=0)
|
||||
cbar = plt.colorbar(cax=cbaxes, orientation='vertical')
|
||||
cbaxes.yaxis.set_ticks_position('left')
|
||||
cbaxes.yaxis.set_tick_params(color="white", which="both")
|
||||
plt.setp(plt.getp(cbaxes.axes, 'yticklabels'), color="white")
|
||||
cbar.outline.set_edgecolor("white")
|
||||
cbaxes.tick_params(axis="y",direction="in", pad=-25)
|
||||
else:
|
||||
try:
|
||||
cbar = plt.colorbar(im, cax=plt.gca().cax)
|
||||
@@ -672,7 +674,10 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
|
||||
if put_title:
|
||||
title = self.snapshot_title(run, title, nml_key, put_time, unit_time)
|
||||
plt.title(title)
|
||||
if embeded:
|
||||
ax.text(x=0.05, y=0.95, s=title, color="white", transform=ax.transAxes)
|
||||
else:
|
||||
plt.title(title)
|
||||
|
||||
for i, plot_overlay in enumerate(overlays):
|
||||
if plot_overlay in self.overlays:
|
||||
@@ -690,6 +695,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
except IndexError:
|
||||
plot_overlay(ax_los, im_extent)
|
||||
|
||||
if embeded:
|
||||
plt.subplots_adjust(left=0, right=1, top=1, bottom=0)
|
||||
|
||||
return PlotInfo(
|
||||
plot_type=PlotType.IMAGE,
|
||||
xaxis_values=np.linspace(im_extent[0], im_extent[1], dmap.shape[0] + 1),
|
||||
|
||||
Reference in New Issue
Block a user