Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • empyre/empyre
  • weber/empyre
  • wessels/empyre
  • bryan/empyre
4 results
Show changes
......@@ -10,7 +10,7 @@ import warnings
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import DivergingNorm
from matplotlib.colors import TwoSlopeNorm
from PIL import Image
from . import colors
......@@ -76,9 +76,10 @@ def imshow(field, axis=None, cmap=None, **kwargs):
elif isinstance(cmap, str): # make sure we have a Colormap object (and not a string):
cmap = plt.get_cmap(cmap)
if cmap.name.replace('_r', '') in DIVERGING_CMAPS: # 'replace' also matches reverted cmaps!
kwargs.setdefault('norm', DivergingNorm(0)) # Diverging colormap should have zero at the symmetry point!
kwargs.setdefault('norm', TwoSlopeNorm(0)) # Diverging colormap should have zero at the symmetry point!
# Set extent in data coordinates (left, right, bottom, top) to kwargs (if not set explicitely):
dim_v, dim_u, s_v, s_u = *squeezed_field.dim, *squeezed_field.scale
dim_v, dim_u = squeezed_field.dim
s_v, s_u = squeezed_field.scale
kwargs.setdefault('extent', (0, dim_u * s_u, 0, dim_v * s_v))
# Plot with the empyre style context:
with use_style('empyre-image'): # Only works on axes created WITHIN context!
......@@ -191,7 +192,8 @@ def colorvec(field, axis=None, **kwargs):
cmap = colors.cmaps.cyclic_cubehelix
rgb = cmap.rgb_from_vector(np.stack((x_comp, y_comp, z_comp), axis=0))
# Set extent in data coordinates (left, right, bottom, top) to kwargs (if not set explicitely):
dim_v, dim_u, s_v, s_u = *squeezed_field.dim, *squeezed_field.scale
dim_v, dim_u = squeezed_field.dim
s_v, s_u = squeezed_field.scale
kwargs.setdefault('extent', (0, dim_u * s_u, 0, dim_v * s_v))
# Plot with the empyre style context:
with use_style('empyre-image'): # Only works on axes created WITHIN context!
......@@ -249,7 +251,8 @@ def cosine_contours(field, axis=None, gain='auto', cmap=None, **kwargs):
contours += 1 # Shift to positive values
contours /= 2 # Rescale to [0, 1]
# Set extent in data coordinates (left, right, bottom, top) to kwargs (if not set explicitely):
dim_v, dim_u, s_v, s_u = *squeezed_field.dim, *squeezed_field.scale
dim_v, dim_u = squeezed_field.dim
s_v, s_u = squeezed_field.scale
kwargs.setdefault('extent', (0, dim_u * s_u, 0, dim_v * s_v))
# Plot with the empyre style context:
with use_style('empyre-image'): # Only works on axes created WITHIN context!
......
......@@ -48,8 +48,8 @@ def new(nrows=1, ncols=1, mode='image', figsize=None, textwidth=None, width_scal
Width and height of the figure in inches, defaults to rcParams["figure.figsize"], which depends on the chosen
stylesheet. If set, this will overwrite all other following parameters.
textwidth : float, optional
The textwidth of your LaTeX document in points, which you can get by using :math:`\the\textwidth`. If this is not None
(the default), this will be used to define the figure size if it is not set explicitely.
The textwidth of your LaTeX document in points, which you can get by using :math:`\the\textwidth`. If this is
not None (the default), this will be used to define the figure size if it is not set explicitely.
width_scale : float, optional
Only meaningful if `textwidth` is set. If it is, `width_scale` will be a scaling factor for the figure width.
Example: if you set this to 0.5, your figure will span half of the textwidth. Default is 1.
......