[plotter] add arrow for axes direction

+ allow change of the color of the text overlays
This commit is contained in:
Noe Brucy
2021-12-01 22:54:47 +01:00
parent 9649ebca25
commit 8ed32d114f
+22 -7
View File
@@ -649,6 +649,8 @@ class Plotter(Aggregator, BaseProcessor):
axes=True, axes=True,
colorbar=True, colorbar=True,
embeded=False, embeded=False,
axes_indicator=None,
overtext_color="w",
**kwargs, **kwargs,
): ):
""" """
@@ -666,6 +668,9 @@ class Plotter(Aggregator, BaseProcessor):
# Put a scalebar by default # Put a scalebar by default
if scalebar is None: if scalebar is None:
scalebar = True scalebar = True
if axes_indicator is None:
axes_indicator = True
if center_space: if center_space:
center = self.current_processor.get_attribute("/maps", "center") center = self.current_processor.get_attribute("/maps", "center")
@@ -709,11 +714,21 @@ class Plotter(Aggregator, BaseProcessor):
f"{scalebar_size} {unit_str(unit_space)[2:-1]}", f"{scalebar_size} {unit_str(unit_space)[2:-1]}",
"lower left", "lower left",
pad=1, pad=1,
color="white", color=overtext_color,
frameon=False, frameon=False,
) )
plt.gca().add_artist(scalebar) plt.gca().add_artist(scalebar)
if axes_indicator:
# A liitle drawing saying what are the axes
plt.annotate('', xy=(0.97, 0.1), xycoords='axes fraction', xytext=(0.865, 0.1),
arrowprops={'arrowstyle': '->', "color" : overtext_color})
plt.annotate('', xy=(0.87, 0.2), xycoords='axes fraction', xytext=(0.87, 0.095),
arrowprops={'arrowstyle': '->', "color" : overtext_color})
plt.annotate(self._ax_title[ax_h], xy=(0.87, 0.2), xytext=(0.89, 0.05),
color=overtext_color, xycoords='axes fraction')
plt.annotate(self._ax_title[ax_v], xy=(0.87, 0.2), xytext=(0.83, 0.12),
color=overtext_color, xycoords='axes fraction')
if axes: if axes:
if xlabel is None: if xlabel is None:
xlabel = self._ax_title[ax_h] xlabel = self._ax_title[ax_h]
@@ -736,9 +751,9 @@ class Plotter(Aggregator, BaseProcessor):
cbar = plt.colorbar(cax=cbaxes, orientation="vertical") cbar = plt.colorbar(cax=cbaxes, orientation="vertical")
cbaxes.yaxis.set_ticks_position("left") cbaxes.yaxis.set_ticks_position("left")
cbaxes.yaxis.set_label_position("left") cbaxes.yaxis.set_label_position("left")
cbaxes.yaxis.set_tick_params(color="white", which="both") cbaxes.yaxis.set_tick_params(color=overtext_color, which="both")
plt.setp(plt.getp(cbaxes.axes, "yticklabels"), color="white") plt.setp(plt.getp(cbaxes.axes, "yticklabels"), color=overtext_color)
cbar.outline.set_edgecolor("white") cbar.outline.set_edgecolor(overtext_color)
cbaxes.tick_params(axis="y", direction="in", pad=-25) cbaxes.tick_params(axis="y", direction="in", pad=-25)
plt.sca(ax) plt.sca(ax)
else: else:
@@ -748,14 +763,14 @@ class Plotter(Aggregator, BaseProcessor):
cbar = plt.colorbar() cbar = plt.colorbar()
if label is not None: if label is not None:
if embeded: if embeded:
cbar.set_label(" " + label, color="white", loc="bottom") cbar.set_label(" " + label, color=overtext_color, loc="bottom")
else: else:
cbar.set_label(label) cbar.set_label(label)
if put_title: if put_title:
title = self.snapshot_title(run, title, nml_key, put_time, unit_time) title = self.snapshot_title(run, title, nml_key, put_time, unit_time)
if embeded: if embeded:
ax.text(x=0.05, y=0.95, s=title, color="white", transform=ax.transAxes) ax.text(x=0.05, y=0.95, s=title, color=overtext_color, transform=ax.transAxes)
else: else:
plt.title(title) plt.title(title)