def test_template_settings(self): template=DefaultPlotStyle(font__weight="bold") self.assertEqual(template["font.weight"],"bold","Setting ytemplate parameter in init failed.") template(font__weight="normal") self.assertEqual(template["font.weight"],"normal","Setting ytemplate parameter in call failed.") template["font.weight"]="bold" self.assertEqual(template["font.weight"],"bold","Setting ytemplate parameter in setitem failed.") del template["font.weight"] self.assertEqual(template["font.weight"],"normal","Resettting template parameter failed.") keys=sorted([x for x in template]) self.assertEqual(sorted(template.keys()),keys,"template.keys() and template.iter() disagree.") attrs=[x for x in dir(template) if template._allowed_attr(x)] length=len(dict(plt.rcParams))+len(attrs) self.assertEqual(len(template),length,"templa length wrong.")
def setUp(self): self.fldr = PlotFolder(path.join(self.datadir, "NLIV"), pattern="*.txt", setas="yx") self.fldr.template = DefaultPlotStyle() self.fldr.template.xformatter = TexEngFormatter self.fldr.template.yformatter = TexEngFormatter
def test_template_settings(self): template = DefaultPlotStyle(font__weight="bold") self.assertEqual(template["font.weight"], "bold", "Setting ytemplate parameter in init failed.") template(font__weight="normal") self.assertEqual(template["font.weight"], "normal", "Setting ytemplate parameter in call failed.") template["font.weight"] = "bold" self.assertEqual(template["font.weight"], "bold", "Setting ytemplate parameter in setitem failed.") del template["font.weight"] self.assertEqual(template["font.weight"], "normal", "Resettting template parameter failed.") keys = sorted([x for x in template]) self.assertEqual(sorted(template.keys()), keys, "template.keys() and template.iter() disagree.") attrs = [x for x in dir(template) if template._allowed_attr(x)] length = len(dict(plt.rcParams)) + len(attrs) self.assertEqual(len(template), length, "templa length wrong.")
"""Simple ploting with a template.""" from Stoner import Data from Stoner.plot.formats import DefaultPlotStyle from cycler import cycler p = Data("sample.txt", setas="xy", template=DefaultPlotStyle()) p.template( # pylint: disable=not-callable axes__prop_cycle=cycler("color", ["r", "g", "b"])) # pylint: disable=not-callable p.plot() p.y += 1.0 p.plot() p.y += 1.0 p.plot()
@author: phygbu """ from numpy import where, append, atleast_2d from scipy.constants import mu_0 from scipy.stats import gmean from os.path import join from Stoner import Data, __home__ from Stoner.Fit import FMR_Power, Inverse_Kittel, Linear from Stoner.plot.formats import DefaultPlotStyle, TexEngFormatter from Stoner.Folders import PlotFolder # set_option("multiprocessing",os.name!="nt") # Customise a plot template template = DefaultPlotStyle() template.xformatter = TexEngFormatter() template.xformatter.unit = "T" template.yformatter = TexEngFormatter def field_sign(r): """Custom function for split""" pos = r["Field"] >= 0 return where(pos, 1, -1) def extra(i, j, d): """Function for customising each individual plot""" d.axvline(x=d["cut"], ls="--") d.title = r"$\nu={:.1f}\,$GHz".format(d.mean("Frequency") / 1e9)
""" from numpy import where, append, row_stack, atleast_2d from scipy.constants import mu_0 from scipy.stats import gmean from os.path import join import os from Stoner import Data, __home__, set_option from Stoner.Fit import FMR_Power, Inverse_Kittel, Linear from Stoner.plot.formats import DefaultPlotStyle, TexEngFormatter from Stoner.Folders import PlotFolder # set_option("multiprocessing",os.name!="nt") # Customise a plot template template = DefaultPlotStyle() template.xformatter = TexEngFormatter() template.xformatter.unit = "T" template.yformatter = TexEngFormatter # Custom function for split def field_sign(r): pos = r["Field"] >= 0 return where(pos, 1, -1) # Function for customising each individual plot def extra(i, j, d): d.axvline(x=d["cut"], ls="--") d.title = r"$\nu={:.1f}\,$GHz".format(d.mean("Frequency") / 1e9) d.xlabel = r"Field $\mu_0H\,$"