Change default behaviour with 10+ plots
This commit is contained in:
parent
0fbfd20a74
commit
223be18c3e
3 changed files with 24 additions and 15 deletions
|
|
@ -377,16 +377,20 @@ def update_rc_params(rc_params):
|
||||||
plt.rcParams.update({key: rc_params[key]})
|
plt.rcParams.update({key: rc_params[key]})
|
||||||
|
|
||||||
|
|
||||||
def generate_colours(palettes):
|
def generate_colours(palettes, kind=None):
|
||||||
|
|
||||||
# Creates a list of all the colours that is passed in the colour_cycles argument. Then makes cyclic iterables of these.
|
if kind == 'single':
|
||||||
colour_collection = []
|
colour_cycle = itertools.cycle(palettes)
|
||||||
for palette in palettes:
|
|
||||||
mod = importlib.import_module("palettable.colorbrewer.%s" % palette[0])
|
|
||||||
colour = getattr(mod, palette[1]).mpl_colors
|
|
||||||
colour_collection = colour_collection + colour
|
|
||||||
|
|
||||||
colour_cycle = itertools.cycle(colour_collection)
|
else:
|
||||||
|
# Creates a list of all the colours that is passed in the colour_cycles argument. Then makes cyclic iterables of these.
|
||||||
|
colour_collection = []
|
||||||
|
for palette in palettes:
|
||||||
|
mod = importlib.import_module("palettable.colorbrewer.%s" % palette[0])
|
||||||
|
colour = getattr(mod, palette[1]).mpl_colors
|
||||||
|
colour_collection = colour_collection + colour
|
||||||
|
|
||||||
|
colour_cycle = itertools.cycle(colour_collection)
|
||||||
|
|
||||||
|
|
||||||
return colour_cycle
|
return colour_cycle
|
||||||
|
|
@ -252,7 +252,7 @@ def read_brml(data, options={}, index=0):
|
||||||
|
|
||||||
start = float(chain.findall('ScanInformation/ScaleAxes/ScaleAxisInfo/Start')[0].text)
|
start = float(chain.findall('ScanInformation/ScaleAxes/ScaleAxisInfo/Start')[0].text)
|
||||||
stop = float(chain.findall('ScanInformation/ScaleAxes/ScaleAxisInfo/Stop')[0].text)
|
stop = float(chain.findall('ScanInformation/ScaleAxes/ScaleAxisInfo/Stop')[0].text)
|
||||||
increment = float(chain.findall('ScanInformation/ScaleAxes/ScaleAxisInfo/Increment')[0].text)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -262,7 +262,7 @@ def read_brml(data, options={}, index=0):
|
||||||
|
|
||||||
intensity = []
|
intensity = []
|
||||||
for r in raw:
|
for r in raw:
|
||||||
if r > 600:
|
if r > 601:
|
||||||
intensity.append(r)
|
intensity.append(r)
|
||||||
|
|
||||||
intensity = np.array(intensity)
|
intensity = np.array(intensity)
|
||||||
|
|
@ -478,9 +478,7 @@ def translate_wavelengths(data, wavelength, to_wavelength=None):
|
||||||
|
|
||||||
def find_wavelength_from_xy(path):
|
def find_wavelength_from_xy(path):
|
||||||
|
|
||||||
print(path)
|
|
||||||
|
|
||||||
|
|
||||||
wavelength_dict = {'Cu': 1.54059, 'Mo': 0.71073}
|
wavelength_dict = {'Cu': 1.54059, 'Mo': 0.71073}
|
||||||
|
|
||||||
with open(path, 'r') as f:
|
with open(path, 'r') as f:
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ def plot_diffractogram(data, options={}):
|
||||||
|
|
||||||
# Update options
|
# Update options
|
||||||
required_options = ['x_vals', 'y_vals', 'ylabel', 'xlabel', 'xunit', 'yunit', 'line', 'scatter', 'xlim', 'ylim', 'normalise', 'offset', 'offset_x', 'offset_y',
|
required_options = ['x_vals', 'y_vals', 'ylabel', 'xlabel', 'xunit', 'yunit', 'line', 'scatter', 'xlim', 'ylim', 'normalise', 'offset', 'offset_x', 'offset_y',
|
||||||
'reflections_plot', 'reflections_indices', 'reflections_data', 'plot_kind', 'palettes', 'interactive', 'rc_params', 'format_params']
|
'reflections_plot', 'reflections_indices', 'reflections_data', 'plot_kind', 'palettes', 'interactive', 'rc_params', 'format_params', 'interactive_session_active']
|
||||||
|
|
||||||
default_options = {
|
default_options = {
|
||||||
'x_vals': '2th',
|
'x_vals': '2th',
|
||||||
|
|
@ -45,6 +45,10 @@ def plot_diffractogram(data, options={}):
|
||||||
'format_params': {},
|
'format_params': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if 'offset_y' not in options.keys():
|
||||||
|
if len(data['path']) > 10:
|
||||||
|
default_options['offset_y'] = 0.05
|
||||||
|
|
||||||
options = aux.update_options(options=options, required_options=required_options, default_options=default_options)
|
options = aux.update_options(options=options, required_options=required_options, default_options=default_options)
|
||||||
|
|
||||||
# Convert data['path'] to list to allow iteration over this to accommodate both single and multiple diffractograms
|
# Convert data['path'] to list to allow iteration over this to accommodate both single and multiple diffractograms
|
||||||
|
|
@ -62,6 +66,7 @@ def plot_diffractogram(data, options={}):
|
||||||
for index in range(len(data['path'])):
|
for index in range(len(data['path'])):
|
||||||
diffractogram, wavelength = xrd.io.read_data(data=data, options=options, index=index)
|
diffractogram, wavelength = xrd.io.read_data(data=data, options=options, index=index)
|
||||||
|
|
||||||
|
|
||||||
data['diffractogram'][index] = diffractogram
|
data['diffractogram'][index] = diffractogram
|
||||||
data['wavelength'][index] = wavelength
|
data['wavelength'][index] = wavelength
|
||||||
|
|
||||||
|
|
@ -113,7 +118,10 @@ def plot_diffractogram(data, options={}):
|
||||||
|
|
||||||
ax = ax[-1]
|
ax = ax[-1]
|
||||||
|
|
||||||
colours = btp.generate_colours(options['palettes'])
|
if len(data['path']) < 10:
|
||||||
|
colours = btp.generate_colours(options['palettes'])
|
||||||
|
else:
|
||||||
|
colours = btp.generate_colours(['black'], kind='single')
|
||||||
|
|
||||||
|
|
||||||
for diffractogram in data['diffractogram']:
|
for diffractogram in data['diffractogram']:
|
||||||
|
|
@ -183,7 +191,6 @@ def plot_diffractogram_interactive(data, options):
|
||||||
|
|
||||||
if not ymax or (ymax < (diffractogram['I'].max())):#+index*options['offset_y'])):
|
if not ymax or (ymax < (diffractogram['I'].max())):#+index*options['offset_y'])):
|
||||||
ymax = diffractogram['I'].max()#+index*options['offset_y']
|
ymax = diffractogram['I'].max()#+index*options['offset_y']
|
||||||
print(ymax)
|
|
||||||
|
|
||||||
|
|
||||||
ymin_start = ymin - 0.1*ymax
|
ymin_start = ymin - 0.1*ymax
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue