def eqdataplot(eq, datasets, ax=None, plot_kwargs=None): """ Plot datapoints corresponding to the components and phases in the eq Dataset. A convenience function for dataplot. Parameters ---------- eq : xarray.Dataset Result of equilibrium calculation. datasets : PickleableTinyDB Database of phase equilibria datasets ax : matplotlib.Axes Default axes used if not specified. plot_kwargs : dict Keyword arguments to pass to dataplot Returns ------- A plot of phase equilibria points as a figure Examples -------- >>> from pycalphad import equilibrium, Database, variables as v >>> from pycalphad.plot.eqplot import eqplot >>> from espei.datasets import load_datasets, recursive_glob >>> datasets = load_datasets(recursive_glob('.', '*.json')) >>> dbf = Database('my_databases.tdb') >>> my_phases = list(dbf.phases.keys()) >>> eq = equilibrium(dbf, ['CU', 'MG', 'VA'], my_phases, {v.P: 101325, v.T: (500, 1000, 10), v.X('MG'): (0, 1, 0.01)}) >>> ax = eqplot(eq) >>> ax = eqdataplot(eq, datasets, ax=ax) """ # TODO: support reference legend conds = OrderedDict([ (_map_coord_to_variable(key), unpack_condition(np.asarray(value))) for key, value in sorted(eq.coords.items(), key=str) if (key == 'T') or (key == 'P') or (key.startswith('X_')) ]) phases = list( map( str, sorted(set(np.array(eq.Phase.values.ravel(), dtype='U')) - {''}, key=str))) comps = list( map( str, sorted(np.array(eq.coords['component'].values, dtype='U'), key=str))) ax = dataplot(comps, phases, conds, datasets, ax=ax, plot_kwargs=plot_kwargs) return ax
def eqdataplot(eq, datasets, ax=None, plot_kwargs=None): """ Plot datapoints corresponding to the components and phases in the eq Dataset. A convenience function for dataplot. Parameters ---------- eq : xarray.Dataset Result of equilibrium calculation. datasets : PickleableTinyDB Database of phase equilibria datasets ax : matplotlib.Axes Default axes used if not specified. plot_kwargs : dict Keyword arguments to pass to dataplot Returns ------- A plot of phase equilibria points as a figure Examples -------- >>> from pycalphad import equilibrium, Database, variables as v # doctest: +SKIP >>> from pycalphad.plot.eqplot import eqplot # doctest: +SKIP >>> from espei.datasets import load_datasets, recursive_glob # doctest: +SKIP >>> datasets = load_datasets(recursive_glob('.', '*.json')) # doctest: +SKIP >>> dbf = Database('my_databases.tdb') # doctest: +SKIP >>> my_phases = list(dbf.phases.keys()) # doctest: +SKIP >>> eq = equilibrium(dbf, ['CU', 'MG', 'VA'], my_phases, {v.P: 101325, v.T: (500, 1000, 10), v.X('MG'): (0, 1, 0.01)}) # doctest: +SKIP >>> ax = eqplot(eq) # doctest: +SKIP >>> ax = eqdataplot(eq, datasets, ax=ax) # doctest: +SKIP """ deprecation_msg = ( "`espei.plot.eqdataplot` is deprecated and will be removed in ESPEI 0.9. " "Users depending on plotting from an `pycalphad.equilibrium` result should use " "`pycalphad.plot.eqplot.eqplot` along with `espei.plot.dataplot` directly. " "Note that pycalphad's mapping can offer signficant reductions in calculation " "time compared to using `equilibrium` followed by `eqplot`." ) warnings.warn(deprecation_msg, category=FutureWarning) # TODO: support reference legend conds = OrderedDict([(_map_coord_to_variable(key), unpack_condition(np.asarray(value))) for key, value in sorted(eq.coords.items(), key=str) if (key == 'T') or (key == 'P') or (key.startswith('X_'))]) phases = list(map(str, sorted(set(np.array(eq.Phase.values.ravel(), dtype='U')) - {''}, key=str))) comps = list(map(str, sorted(np.array(eq.coords['component'].values, dtype='U'), key=str))) ax = dataplot(comps, phases, conds, datasets, ax=ax, plot_kwargs=plot_kwargs) return ax