File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1239,10 +1239,15 @@ def is_list(variable):
12391239 aspect = this_aspect ,
12401240 vmin = this_vmin ,
12411241 vmax = this_vmax ,
1242+ logscale = this_logscale ,
12421243 ** this_kwargs ,
12431244 )
12441245 )
12451246 else :
1247+ if this_vmin is None :
1248+ this_vmin = min (np .min (w ).values for w in v )
1249+ if this_vmax is None :
1250+ this_vmax = max (np .max (w ).values for w in v )
12461251 for w in v :
12471252 blocks .append (
12481253 animate_line (
@@ -1254,6 +1259,7 @@ def is_list(variable):
12541259 aspect = this_aspect ,
12551260 vmin = this_vmin ,
12561261 vmax = this_vmax ,
1262+ logscale = this_logscale ,
12571263 label = w .name ,
12581264 ** this_kwargs ,
12591265 )
Original file line number Diff line number Diff line change @@ -520,6 +520,7 @@ def animate_line(
520520 axis_coords = None ,
521521 vmin = None ,
522522 vmax = None ,
523+ logscale = False ,
523524 fps = 10 ,
524525 save_as = None ,
525526 sep_pos = None ,
@@ -555,6 +556,12 @@ def animate_line(
555556 vmax : float, optional
556557 Maximum value to use for colorbar. Default is to use maximum value of
557558 data across whole timeseries.
559+ logscale : bool or float, optional
560+ If True, default to a logarithmic color scale instead of a linear one.
561+ If a non-bool type is passed it is treated as a float used to set the linear
562+ threshold of a symmetric logarithmic scale as
563+ linthresh=min(abs(vmin),abs(vmax))*logscale, defaults to 1e-5 if True is
564+ passed.
558565 fps : int, optional
559566 Frames per second of resulting gif
560567 save_as : True or str, optional
@@ -640,6 +647,17 @@ def animate_line(
640647 y_label = y_label + f" [{ data .units } ]"
641648 ax .set_ylabel (y_label )
642649
650+ if logscale :
651+ if vmin * vmax > 0.0 :
652+ ax .set_yscale ("log" )
653+ else :
654+ if not isinstance (logscale , bool ):
655+ linear_scale = logscale
656+ else :
657+ linear_scale = 1.0e-5
658+ linear_threshold = min (abs (vmin ), abs (vmax )) * linear_scale
659+ ax .set_yscale ("symlog" , linthresh = linear_threshold )
660+
643661 # Plot separatrix
644662 if sep_pos :
645663 ax .plot_vline (sep_pos , "--" )
You can’t perform that action at this time.
0 commit comments