Commit 8026010c authored by marc barbarosa's avatar marc barbarosa
Browse files

better handling vmin, vmax

parent 4ee8210c
Pipeline #18963325 failed with stage
in 66 minutes and 3 seconds
......@@ -1141,19 +1141,23 @@ def plot_imshow_plotly(args, prop, data, z):
else:
cmap = "Viridis"
#z = z.transpose()[:, ::-1]
if prop.vmin is None and prop.vmax is None:
vmax = np.max(abs(z))
vmin = -vmax
elif prop.vmin is None:
vmin = np.min(z)
vmax = prop.vmax
elif prop.vmax is None:
vmin = prop.vmin
vmax = np.max(z)
else:
vmin = prop.vmin
vmax = prop.vmax
vminmax = [None, None]
for i, [pvm, minmax, sign] in enumerate(zip([prop.vmin, prop.vmax],
[np.min(z), np.max(z)], [-1.0, 1.0])):
if isinstance(pvm, str):
if pvm == "equal":
vminmax[i] = sign*np.max(abs(z))
else:
vminmax[i] = float(pvm)*minmax
elif pvm is None:
vminmax[i] = minmax
elif isinstance(pvm, float):
vminmax[i] = pvm
else:
raise ValueError("wrong option for prop.vmin or prop.vmax")
vmin, vmax = vminmax[0], vminmax[1]
z = z.T[::-1, :]
if prop.plan== 'x':
......@@ -1239,15 +1243,22 @@ def plot_imshow_spatial(args, prop, ax, data, z):
y_max = data.box[1][1]*units.Bohr
z_max = data.box[1][2]*units.Bohr
#z = z.transpose()[:, ::-1]
if prop.vmax is None:
vmax = np.max(abs(z))
else:
vmax = prop.vmax
if prop.vmin is None:
vmin = -vmax
else:
vmin = prop.vmin
vminmax = [None, None]
for i, [pvm, minmax, sign] in enumerate(zip([prop.vmin, prop.vmax],
[np.min(z), np.max(z)], [-1.0, 1.0])):
if isinstance(pvm, str):
if pvm == "equal":
vminmax[i] = sign*np.max(abs(z))
else:
vminmax[i] = float(pvm)*minmax
elif pvm is None:
vminmax[i] = minmax
elif isinstance(pvm, float):
vminmax[i] = pvm
else:
raise ValueError("wrong option for prop.vmin or prop.vmax")
vmin, vmax = vminmax[0], vminmax[1]
z = z.T[::-1, :]
if prop.plan== 'x':
......@@ -1355,7 +1366,7 @@ def plot_imshow_spatial(args, prop, ax, data, z):
if prop.cbar_yticklabels is not None:
ticks = np.linspace(vmin, vmax, len(prop.cbar_yticklabels))
prop.cbar = plt.colorbar(im, orientation=prop.cbar_orientation, ticks = ticks, cax=prop.cbar_cax,
fraction=0.046)
fraction=0.07)
prop.cbar.ax.set_yticklabels(prop.cbar_yticklabels)
else:
prop.cbar = plt.colorbar(im, orientation=prop.cbar_orientation, cax=prop.cbar_cax)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment