diff --git a/worm_algorithm/block_configs.ipynb b/worm_algorithm/block_configs.ipynb index b70d001..d660800 100644 --- a/worm_algorithm/block_configs.ipynb +++ b/worm_algorithm/block_configs.ipynb @@ -9,11 +9,11 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": { "ExecuteTime": { - "end_time": "2018-02-14T07:02:03.470104Z", - "start_time": "2018-02-14T07:02:03.402771Z" + "end_time": "2018-02-15T08:59:30.779393Z", + "start_time": "2018-02-15T08:59:30.060505Z" } }, "outputs": [], @@ -25,7 +25,7 @@ "import os\n", "from worm_simulation import WormSimulation\n", "from bonds import Bonds\n", - "from iterated_blocking import *\n", + "from block_configs import *\n", "from specific_heat import SpecificHeat\n", "from pca import PrincipalComponent\n", "from specific_heat import SpecificHeat\n", @@ -52,11 +52,11 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "metadata": { "ExecuteTime": { - "end_time": "2018-02-14T07:02:20.821016Z", - "start_time": "2018-02-14T07:02:20.779909Z" + "end_time": "2018-02-15T08:59:32.607159Z", + "start_time": "2018-02-15T08:59:32.555761Z" } }, "outputs": [], @@ -749,11 +749,11 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 5, "metadata": { "ExecuteTime": { - "end_time": "2018-02-14T08:53:44.026829Z", - "start_time": "2018-02-14T07:18:52.813715Z" + "end_time": "2018-02-15T19:15:38.559436Z", + "start_time": "2018-02-15T08:59:40.004226Z" }, "scrolled": true }, @@ -763,31 +763,116 @@ "output_type": "stream", "text": [ "Reading from ../data/configs/32_lattice/separated_data/32_config_2.4.txt\n", - "Saving to: ../data/blocked_configs/32_lattice/double_bonds_1/16_blocked_configs_2.4.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.4.txt\n", "\n", "Reading from ../data/configs/32_lattice/separated_data/32_config_2.5.txt\n", - "Saving to: ../data/blocked_configs/32_lattice/double_bonds_1/16_blocked_configs_2.5.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.5.txt\n", "\n", - "Reading from ../data/configs/32_lattice/separated_data/32_config_2.75.txt\n" - ] - }, - { - "ename": "KeyboardInterrupt", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mf\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mconfigs32_files\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mblock_configs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdouble_bonds_value\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m~/worm_algorithm/worm_algorithm/iterated_blocking.py\u001b[0m in \u001b[0;36mblock_configs\u001b[0;34m(config_file, double_bonds_value, out_dir)\u001b[0m\n", - "\u001b[0;32m~/worm_algorithm/worm_algorithm/iterated_blocking.py\u001b[0m in \u001b[0;36m_block_config\u001b[0;34m(config, num_block_steps, double_bonds_value)\u001b[0m\n", - "\u001b[0;31mKeyboardInterrupt\u001b[0m: " + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.75.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.75.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.7.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.7.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.6.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.6.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.48.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.48.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.2.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.2.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.3.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.3.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.65.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.65.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.1.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.1.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.0.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.0.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.15.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.15.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_1.4.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_1.4.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_3.4.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_3.4.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_1.85.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_1.85.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_1.7.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_1.7.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_3.5.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_3.5.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_3.1.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_3.1.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_1.3.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_1.3.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_1.95.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_1.95.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_1.2.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_1.2.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_3.0.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_3.0.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_3.2.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_3.2.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_1.0.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_1.0.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.05.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.05.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_1.1.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_1.1.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_3.3.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_3.3.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.35.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.35.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_1.9.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_1.9.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.25.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.25.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_1.8.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_1.8.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.55.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.55.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.45.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.45.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.8.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.8.txt\n", + "\n", + "Reading from ../data/configs/32_lattice/separated_data/32_config_2.9.txt\n", + "Saving to: ../data/blocked_configs/32_lattice/double_bonds_2/16_blocked_configs_2.9.txt\n", + "\n" ] } ], "source": [ "for f in configs32_files:\n", - " block_configs(f, double_bonds_value=1)" + " block_configs(f, double_bonds_value=2)" ] }, { diff --git a/worm_algorithm/bonds.py b/worm_algorithm/bonds.py index f94c6e5..b3ff36d 100644 --- a/worm_algorithm/bonds.py +++ b/worm_algorithm/bonds.py @@ -38,19 +38,26 @@ def __init__(self, L, run=False, num_steps=1E7, verbose=True, block_val=0, write=True, write_blocked=True): """Initialize Bonds class, which can also be used to run the simulation.""" - if T_arr is None: - WormSimulation.__init__(self, L, run, num_steps, verbose, - T_start, T_end, T_step) - else: - WormSimulation.__init__(self, L, run, num_steps, verbose, - T_arr=T_arr) + # if T_arr is None: + # WormSimulation.__init__(self, L, run, num_steps, verbose, + # T_start, T_end, T_step) + # else: + # WormSimulation.__init__(self, L, run, num_steps, verbose, + # T_arr=T_arr) self._L = L self._num_bonds = 2*self._L*self._L - self._bonds_dir = '../data/bonds/lattice_{}/'.format(self._L) - self._bond_map_dir = '../data/bond_map/lattice_{}/'.format(self._L) - self.__map_file = self._bond_map_dir + 'bond_map_{}.txt'.format(L) + self._num_steps = num_steps + self._verbose = verbose + # self._bond_flag = bond_flag + self._set_dirs() + if T_arr is None: + self._T_range = np.arange(T_start, T_end, T_step) + else: + self._T_range = T_arr + self._run = run self._map = self._get_map() - self._dict = self._get_bonds() + # self._dict = self._get_bonds() + self._dict = self.load_bonds() self._mapped_bonds = self._map_bonds() tup = self._get_active_bonds() self._active_bonds, self._active_x_bonds, self._active_y_bonds = tup @@ -62,6 +69,77 @@ def __init__(self, L, run=False, num_steps=1E7, verbose=True, self.write_config_data() if write_blocked: self.write_blocked_config_data() + + def _set_dirs(self): + self._sim_dir = os.getcwd() + self._bonds_dir = f"../data/bonds/lattice_{self._L}/" + self._observables_dir = f"../data/observables/lattice_{self._L}/" + self._config_dir = f"../data/bonds/lattice_{self._L}/" + self._num_bonds_dir = f"../data/num_bonds/lattice_{self._L}/" + self._bond_map_dir = f"../data/bond_map_lattice_{self._L}/" + self.__map_file = self._bond_map_dir + f"bond_map_{self._L}.txt" + self._setup_dir = "../data/setup/" + if not os.path.exists(self._observables_dir): + os.makedirs(self._observables_dir) + if not os.path.exists(self._config_dir): + os.makedirs(self._config_dir) + if not os.path.exists(self._num_bonds_dir): + os.makedirs(self._num_bonds_dir) + if not os.path.exists(self._bond_map_dir): + os.makedirs(self._bond_map_dir) + if not os.path.exists(self._setup_dir): + os.makedirs(self._setup_dir) + + def prepare_input(self, T, num_steps): + """Create txt file to be read in as parameters for the C++ method.""" + seed = T + np.random.randint(1E4) * np.random.rand() + try: + input_file = self._setup_dir + 'input.txt' + with open(input_file, 'w') as f: + f.write("%i %.12f %i %.32f %i\n" % (self._L, T, num_steps, + seed, self._bond_flag)) + except IOError: + print(f"Unable to locate {input_file} in {self._setup_dir}") + raise + + def remove_old_data(self): + """Remove old configuration data from previous runs.""" + try: + files_ = os.listdir(self._config_dir) + for _file in files_: + if _file.endswith('.txt'): + os.remove(self._config_dir + _file) + except ValueError: + print(f"{self._config_dir} is already empty. Exiting.") + raise + + def make(self): + """Call the makefile and compile the C++ method, creating the + executable. + + NOTE: The C++ method completes the simulation for a fixed temperature, + defined in 'input.txt', which is recreated for each run. + """ + try: + print("compilation -- start\n") + os.chdir('./src') + os.system('make clean') + os.system('make') + os.chdir('../') + print('compilation -- done\n') + self._prog = './src/worm_ising_2d' + if not os.path.isfile(self._prog): + print(f"ERROR: Unable to find executable file {self._prog}") + raise IOError + except (IOError, OSError): + print("Directory structure invalid. Exiting.") + raise + + def run(self): + """Main method for running the simulation and storing relevant + variables.""" + pass + def _get_raw_bonds(self): """ Read in raw bond/site data. @@ -117,6 +195,66 @@ def _get_map(self): # _map[key] = [tuple(start_site), tuple(end_site)] return _map + def _load_bonds(self, file): + """Read in bond configuration from file and map to pairs of sites. + + NOTE: Each file corresponds to a particular temperature and will + contain multiple configurations obtained from the C++ simulation. + + Returns: + config_dict (dict): Dictionary containing each distinct bond + configuration. config_dict.keys() enumerate each of the distinct + configurations, and config_dict.values() is a dictionary of the + form: + {bond_idx_0: status, + bond_idx_1: status, + ... + bond_idx_N: status} + where the bond indices run from 0 to 2 * L * L, and the status + corresponds to its occupancy (status == 0 implies bond is not + active) + """ + bonds = pd.read_csv(file, header=None, engine='c', + delim_whitespace=True).values + num_configs = bonds.shape[0] / self._num_bonds + split_configs = np.split(bonds, num_configs) + config_dict = {} + for idx, config in enumerate(split_configs): + bond_dict = {} + for row in config: + b_idx = row[0] + bond_dict[b_idx] = row[1] + config_dict[idx] = bond_dict + return config_dict + + def load_bonds(self): + """ Read in bond data for each temperature. + + Returns: + _dict (dict): Dictionary containing active bonds and their indices + for each temperature. _dict has the following attributes: + _dict.keys(): Temperature (str) + _dict.values(): [bond_idx, status], where status = 1 if bond is + active, 0 otherwise. + """ + try: + _dict = {} + bond_files = [ + self._bonds_dir + f for f in os.listdir(self._bonds_dir) + if f.endswith('.txt') + ] + split_files = [i.split('/') for i in bond_files] + temp_strings = [i[-1].split('_')[-1].rstrip('.txt').rstrip('0') for + i in split_files] + for idx, f in enumerate(bond_files): + key = temp_strings[idx] + _dict[key] = self._load_bonds(f) + return _dict + except OSError: + print("Unable to locate bond files. Exiting.") + raise + + def _get_bonds(self): """ Read in bond data for each temperature. diff --git a/worm_algorithm/generate_data.ipynb b/worm_algorithm/generate_data.ipynb index ebc09ec..b09c8c3 100644 --- a/worm_algorithm/generate_data.ipynb +++ b/worm_algorithm/generate_data.ipynb @@ -182,8 +182,7 @@ "ExecuteTime": { "end_time": "2018-02-14T09:30:06.730117Z", "start_time": "2018-02-14T09:27:32.153880Z" - }, - "collapsed": true + } }, "outputs": [ { diff --git a/worm_algorithm/iterated_blocking.ipynb b/worm_algorithm/iterated_blocking.ipynb index ec62fd4..3fbb2d7 100644 --- a/worm_algorithm/iterated_blocking.ipynb +++ b/worm_algorithm/iterated_blocking.ipynb @@ -19,8 +19,8 @@ "execution_count": 1, "metadata": { "ExecuteTime": { - "end_time": "2018-02-11T03:55:40.361738Z", - "start_time": "2018-02-11T03:55:38.826191Z" + "end_time": "2018-03-07T00:39:54.202152Z", + "start_time": "2018-03-07T00:39:52.431464Z" } }, "outputs": [], @@ -36,7 +36,7 @@ "from bonds import Bonds\n", "from specific_heat import SpecificHeat\n", "from pca import PrincipalComponent\n", - "from iterated_blocking import *\n", + "from block_configs import *\n", "from utils import *\n", "#from count_bonds import *\n", "from specific_heat import SpecificHeat\n", @@ -56,7 +56,8 @@ "plt.rc('text', usetex=True)\n", "mpl.rcParams['xtick.labelsize'] = label_size \n", "mpl.rcParams['ytick.labelsize'] = label_size \n", - "\n", + "#mathtext.fontset : cm # Should be 'cm' (Computer Modern), 'stix',\n", + " # 'stixsans' or 'custom'\n", "Tc = 2./np.log(1+np.sqrt(2)) # critical temperature" ] }, @@ -72,8 +73,8 @@ "execution_count": 2, "metadata": { "ExecuteTime": { - "end_time": "2018-02-11T03:55:43.409921Z", - "start_time": "2018-02-11T03:55:43.368643Z" + "end_time": "2018-03-07T00:39:56.668662Z", + "start_time": "2018-03-07T00:39:56.588890Z" }, "code_folding": [] }, @@ -101,6 +102,33 @@ ")" ] }, + { + "cell_type": "markdown", + "metadata": { + "heading_collapsed": true + }, + "source": [ + "## Load Judah's Data" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "ExecuteTime": { + "end_time": "2018-02-20T19:01:24.410273Z", + "start_time": "2018-02-20T19:01:24.372046Z" + }, + "hidden": true + }, + "outputs": [], + "source": [ + "hotrg_data = pd.read_csv('../data/hotrg_2s-iterate_x32.txt', header=None,\n", + " engine='c', delim_whitespace=True).values\n", + "phi_pi_data = pd.read_csv('../data/phi-pi-div-12_2s-iterate_x32.txt',\n", + " header=None, engine='c', delim_whitespace=True).values" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -113,8 +141,8 @@ "execution_count": 3, "metadata": { "ExecuteTime": { - "end_time": "2018-02-09T15:10:23.520016Z", - "start_time": "2018-02-09T15:10:23.458969Z" + "end_time": "2018-03-07T00:40:02.398183Z", + "start_time": "2018-03-07T00:40:02.339280Z" } }, "outputs": [ @@ -127,7 +155,7 @@ } ], "source": [ - "count_bonds32 = CountBonds(L=32, load=True)" + "count_bonds32b = CountBonds(L=32, load=True)" ] }, { @@ -135,8 +163,8 @@ "execution_count": 4, "metadata": { "ExecuteTime": { - "end_time": "2018-02-09T15:10:26.273919Z", - "start_time": "2018-02-09T15:10:26.202983Z" + "end_time": "2018-03-07T00:40:02.930848Z", + "start_time": "2018-03-07T00:40:02.889903Z" } }, "outputs": [ @@ -149,7 +177,7 @@ } ], "source": [ - "count_bonds16 = CountBonds(L=16, load=True, \n", + "count_bonds16b = CountBonds(L=16, load=True, \n", " data_dir=config_dir32_b16, \n", " save_dir=save_dir16)" ] @@ -159,8 +187,8 @@ "execution_count": 5, "metadata": { "ExecuteTime": { - "end_time": "2018-02-09T15:10:43.391936Z", - "start_time": "2018-02-09T15:10:43.338061Z" + "end_time": "2018-03-07T00:40:03.383344Z", + "start_time": "2018-03-07T00:40:03.337307Z" } }, "outputs": [ @@ -173,7 +201,7 @@ } ], "source": [ - "count_bonds8 = CountBonds(L=8, load=True,\n", + "count_bonds8b = CountBonds(L=8, load=True,\n", " data_dir=config_dir16_b8,\n", " save_dir=save_dir8)" ] @@ -183,8 +211,8 @@ "execution_count": 6, "metadata": { "ExecuteTime": { - "end_time": "2018-02-09T15:10:45.023167Z", - "start_time": "2018-02-09T15:10:44.969688Z" + "end_time": "2018-03-07T00:40:03.891371Z", + "start_time": "2018-03-07T00:40:03.850395Z" } }, "outputs": [ @@ -197,7 +225,7 @@ } ], "source": [ - "count_bonds4 = CountBonds(L=4, load=True, \n", + "count_bonds4b = CountBonds(L=4, load=True, \n", " data_dir=config_dir8_b4,\n", " save_dir=save_dir4)" ] @@ -207,8 +235,8 @@ "execution_count": 7, "metadata": { "ExecuteTime": { - "end_time": "2018-02-09T15:10:46.877561Z", - "start_time": "2018-02-09T15:10:46.817696Z" + "end_time": "2018-03-07T00:40:06.180229Z", + "start_time": "2018-03-07T00:40:06.137209Z" } }, "outputs": [ @@ -221,7 +249,7 @@ } ], "source": [ - "count_bonds2 = CountBonds(L=2, load=True,\n", + "count_bonds2b = CountBonds(L=2, load=True,\n", " data_dir=config_dir4_b2,\n", " save_dir=save_dir2)" ] @@ -356,9 +384,7 @@ }, { "cell_type": "markdown", - "metadata": { - "heading_collapsed": true - }, + "metadata": {}, "source": [ "## Run CountBonds on blocked configs" ] @@ -366,8 +392,7 @@ { "cell_type": "markdown", "metadata": { - "heading_collapsed": true, - "hidden": true + "heading_collapsed": true }, "source": [ "### L = 32" @@ -396,8 +421,7 @@ { "cell_type": "markdown", "metadata": { - "heading_collapsed": true, - "hidden": true + "heading_collapsed": true }, "source": [ "### L = 16" @@ -424,8 +448,7 @@ { "cell_type": "markdown", "metadata": { - "heading_collapsed": true, - "hidden": true + "heading_collapsed": true }, "source": [ "### L = 8" @@ -452,8 +475,7 @@ { "cell_type": "markdown", "metadata": { - "heading_collapsed": true, - "hidden": true + "heading_collapsed": true }, "source": [ "### L = 4" @@ -479,9 +501,7 @@ }, { "cell_type": "markdown", - "metadata": { - "hidden": true - }, + "metadata": {}, "source": [ "### L = 2" ] @@ -493,8 +513,7 @@ "ExecuteTime": { "end_time": "2018-02-07T00:20:18.853445Z", "start_time": "2018-02-07T00:19:55.133930Z" - }, - "hidden": true + } }, "outputs": [], "source": [ @@ -512,81 +531,84 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 11, "metadata": { "ExecuteTime": { - "end_time": "2018-02-09T15:11:06.015641Z", - "start_time": "2018-02-09T15:11:05.838006Z" + "end_time": "2018-03-07T00:42:43.393935Z", + "start_time": "2018-03-07T00:42:43.255347Z" } }, "outputs": [], "source": [ - "Nb32 = np.array([\n", - " (i[0], i[1]) for i in list(count_bonds32.bond_stats.values())\n", + "Nb32b = np.array([\n", + " (i[0], i[1]) for i in list(count_bonds32b.bond_stats.values())\n", "])\n", - "delta_Nb32 = np.array([\n", - " (i[2], i[3]) for i in list(count_bonds32.bond_stats.values())\n", + "delta_Nb32b = np.array([\n", + " (i[2], i[3]) for i in list(count_bonds32b.bond_stats.values())\n", "])\n", - "Nb32_temps = np.array([\n", - " float(i) for i in list(count_bonds32.bond_stats.keys())\n", + "Nb32b_temps = np.array([\n", + " float(i) for i in list(count_bonds32b.bond_stats.keys())\n", "])\n", "\n", - "Nb16 = np.array([\n", - " (i[0], i[1]) for i in list(count_bonds16.bond_stats.values())\n", + "Nb16b = np.array([\n", + " (i[0], i[1]) for i in list(count_bonds16b.bond_stats.values())\n", "])\n", - "delta_Nb16 = np.array([\n", - " (i[2], i[3]) for i in list(count_bonds16.bond_stats.values())\n", + "delta_Nb16b = np.array([\n", + " (i[2], i[3]) for i in list(count_bonds16b.bond_stats.values())\n", "])\n", - "Nb16_temps = np.array([\n", - " float(i) for i in list(count_bonds16.bond_stats.keys())\n", + "Nb16b_temps = np.array([\n", + " float(i) for i in list(count_bonds16b.bond_stats.keys())\n", "])\n", "\n", - "Nb8 = np.array([\n", - " (i[0], i[1]) for i in list(count_bonds8.bond_stats.values())\n", + "Nb8b = np.array([\n", + " (i[0], i[1]) for i in list(count_bonds8b.bond_stats.values())\n", "])\n", - "delta_Nb8 = np.array([\n", - " (i[2], i[3]) for i in list(count_bonds8.bond_stats.values())\n", + "delta_Nb8b = np.array([\n", + " (i[2], i[3]) for i in list(count_bonds8b.bond_stats.values())\n", "])\n", - "Nb8_temps = np.array([\n", - " float(i) for i in list(count_bonds8.bond_stats.keys())\n", + "Nb8b_temps = np.array([\n", + " float(i) for i in list(count_bonds8b.bond_stats.keys())\n", "])\n", "\n", - "Nb4 = np.array([\n", - " (i[0], i[1]) for i in list(count_bonds4.bond_stats.values())\n", + "Nb4b = np.array([\n", + " (i[0], i[1]) for i in list(count_bonds4b.bond_stats.values())\n", "])\n", - "delta_Nb4 = np.array([\n", - " (i[2], i[3]) for i in list(count_bonds4.bond_stats.values())\n", + "delta_Nb4b = np.array([\n", + " (i[2], i[3]) for i in list(count_bonds4b.bond_stats.values())\n", "])\n", - "Nb4_temps = np.array([\n", - " float(i) for i in list(count_bonds4.bond_stats.keys())\n", + "Nb4b_temps = np.array([\n", + " float(i) for i in list(count_bonds4b.bond_stats.keys())\n", "])\n", "\n", - "Nb2 = np.array([\n", - " (i[0], i[1]) for i in list(count_bonds2.bond_stats.values())\n", + "Nb2b = np.array([\n", + " (i[0], i[1]) for i in list(count_bonds2b.bond_stats.values())\n", "])\n", - "delta_Nb2 = np.array([\n", - " (i[2], i[3]) for i in list(count_bonds2.bond_stats.values())\n", + "delta_Nb2b = np.array([\n", + " (i[2], i[3]) for i in list(count_bonds2b.bond_stats.values())\n", "])\n", - "Nb2_temps = np.array([\n", - " float(i) for i in list(count_bonds2.bond_stats.keys())\n", + "Nb2b_temps = np.array([\n", + " float(i) for i in list(count_bonds2b.bond_stats.keys())\n", "])" ] }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "heading_collapsed": true + }, "source": [ "## Import Yannicks TRG data" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 68, "metadata": { "ExecuteTime": { - "end_time": "2018-02-09T15:11:10.059734Z", - "start_time": "2018-02-09T15:11:10.010885Z" - } + "end_time": "2018-02-26T12:11:03.734285Z", + "start_time": "2018-02-26T12:11:03.685217Z" + }, + "hidden": true }, "outputs": [], "source": [ @@ -596,250 +618,8037 @@ " delim_whitespace=True, header=None).values" ] }, + { + "cell_type": "markdown", + "metadata": { + "heading_collapsed": true + }, + "source": [ + "## Plot $T_{1111}$ vs. $\\left(T - T_c^{(2s)}\\right) / L$" + ] + }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 82, + "metadata": { + "ExecuteTime": { + "end_time": "2018-02-26T12:19:36.256844Z", + "start_time": "2018-02-26T12:19:36.209793Z" + }, + "hidden": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(5, 50)" + ] + }, + "execution_count": 82, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.array([(val - Tc2s) / sizes[idx] for idx, val in enumerate(trg_temps_)]).shape" + ] + }, + { + "cell_type": "code", + "execution_count": 130, "metadata": { "ExecuteTime": { - "end_time": "2018-02-09T15:11:11.497759Z", - "start_time": "2018-02-09T15:11:11.444273Z" + "end_time": "2018-02-26T13:24:29.640686Z", + "start_time": "2018-02-26T13:24:29.604729Z" + }, + "hidden": true + }, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "unexpected character after line continuation character (, line 1)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m maplotlib.rc('text.latex', preamble=\\usepackage{amsmath},\\usepackage{amssymb})\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m unexpected character after line continuation character\n" + ] } + ], + "source": [ + "maplotlib.rc('text.latex', preamble=\\usepackage{amsmath},\\usepackage{amssymb})" + ] + }, + { + "cell_type": "code", + "execution_count": 131, + "metadata": { + "ExecuteTime": { + "end_time": "2018-02-26T13:28:40.024710Z", + "start_time": "2018-02-26T13:28:39.985781Z" + }, + "hidden": true + }, + "outputs": [], + "source": [ + "mpl.rcParams['ytick.labelsize'] = label_size \n", + "mpl.rcParams['mathtext.fontset'] = 'stix'\n", + "# Should be 'cm' (Computer Modern), 'stix',\n", + " # 'stixsans' or 'custom'" + ] + }, + { + "cell_type": "code", + "execution_count": 132, + "metadata": { + "ExecuteTime": { + "end_time": "2018-02-26T13:28:47.158268Z", + "start_time": "2018-02-26T13:28:43.710142Z" + }, + "hidden": true, + "scrolled": false }, "outputs": [ { "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Saving file to: ../plots/iterated_blocking/bond_stats/Nb_avg_hotrg_32_pi_12.png\n" + ] + }, + { + "data": { + "text/plain": [ + "(,\n", + " )" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "hotrg_err = np.zeros(len(hotrg_data[:,0]))\n", + "Nb_tempsb = np.array([(Nb32b_temps),# - Tc0),\n", + " (hotrg_data[:,0]),# - Tc0),\n", + " (phi_pi_data[:,0])])# - Tc0)])\n", + "Nb_valsb = np.array([Nb32b[:,0]/(32*32),\n", + " hotrg_data[:,1],\n", + " phi_pi_data[:,1]])\n", + "Nb_errb = np.array([Nb32b[:,1]/(32*32), hotrg_err, hotrg_err])\n", + "Nb_values_dictb = {'x': Nb_tempsb, 'y': Nb_valsb, 'y_err': Nb_errb}\n", + "fig_labels = np.array([r\"$\\langle N_b^{(32)}\\rangle/V$\", r\"$T_{1111}^{(0)}$\", \n", + " r\"$T_{1111}^{(0)} \\,\\,\\, (\\phi = \\pi/12)$\"])\n", + " #r\"$T_{1111}^{(\\phi = \\pi/12)}$\"])\n", + "x_label = r\"$T$\"# % scale_factor\n", + "#y_label = r\"$\\langle N_b\\rangle/V$\"\n", + "y_label = r\"\"\n", + "labels = {'fig_labels': fig_labels, 'x_label': x_label, 'y_label': y_label}\n", + "limits = {'x_lim': (1., 3.5)}\n", + "Nb_plot_dirb = '../plots/iterated_blocking/bond_stats/Nb_avg/'\n", + "Nb_plot_numb = get_plot_num(Nb_plot_dirb)\n", + "#Nb_plot_fileb = Nb_plot_dirb + str(Nb_plot_numb)\n", + "Nb_plot_numb = get_plot_num('../plots/iterated_blocking/bond_stats/Nb_avg/')\n", + "errorbar_plot(Nb_values_dictb, labels, \n", + " out_file='../plots/iterated_blocking/bond_stats/Nb_avg_hotrg_32_pi_12.png',\n", + " limits=limits, Tc_line=0)" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": { + "ExecuteTime": { + "end_time": "2018-02-21T18:41:34.195615Z", + "start_time": "2018-02-21T18:41:31.800329Z" + }, + "hidden": true + }, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Saving file to: ../plots/iterated_blocking/bond_stats/Nb_avg_hotrg_8_pi_12.png\n" + ] + }, + { + "data": { + "text/plain": [ + "(,\n", + " )" + ] + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "hotrg_err = np.zeros(len(hotrg_data[:,0]))\n", + "Nb_tempsb = np.array([(Nb8b_temps),# - Tc0),\n", + " (hotrg_data[:,0]),# - Tc0),\n", + " (phi_pi_data[:,0])])# - Tc0)])\n", + "Nb_valsb = np.array([Nb8b[:,0]/(8*8),\n", + " hotrg_data[:,3],\n", + " phi_pi_data[:,3]])\n", + "Nb_errb = np.array([Nb8b[:,1]/(8*8), hotrg_err, hotrg_err])\n", + "Nb_values_dictb = {'x': Nb_tempsb, 'y': Nb_valsb, 'y_err': Nb_errb}\n", + "fig_labels = np.array([r\"$\\langle N_b^{(8)}\\rangle/V$\", r\"$T_{1111}^{(2)}$\", \n", + " r\"$T_{1111}^{(2)} \\,\\,\\, (\\phi = \\pi/12)$\"])\n", + "x_label = r\"$T$\"# % scale_factor\n", + "#y_label = r\"$\\langle N_b\\rangle/V$\"\n", + "y_label = r\"\"\n", + "labels = {'fig_labels': fig_labels, 'x_label': x_label, 'y_label': y_label}\n", + "limits = {'x_lim': (1., 3.5)}\n", + "Nb_plot_dirb = '../plots/iterated_blocking/bond_stats/Nb_avg/'\n", + "Nb_plot_numb = get_plot_num(Nb_plot_dirb)\n", + "#Nb_plot_fileb = Nb_plot_dirb + str(Nb_plot_numb)\n", + "Nb_plot_numb = get_plot_num('../plots/iterated_blocking/bond_stats/Nb_avg/')\n", + "errorbar_plot(Nb_values_dictb, labels, \n", + " out_file='../plots/iterated_blocking/bond_stats/Nb_avg_hotrg_8_pi_12.png',\n", + " limits=limits, Tc_line=0)" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": { + "ExecuteTime": { + "end_time": "2018-02-21T18:42:29.741125Z", + "start_time": "2018-02-21T18:42:27.242916Z" + }, + "hidden": true + }, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Saving file to: ../plots/iterated_blocking/bond_stats/Nb_avg_hotrg_2_pi_12.png\n" + ] + }, + { + "data": { + "text/plain": [ + "(,\n", + " )" + ] + }, + "execution_count": 67, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "hotrg_err = np.zeros(len(hotrg_data[:,0]))\n", + "Nb_tempsb = np.array([(Nb2b_temps),# - Tc0),\n", + " (hotrg_data[:,0]),# - Tc0),\n", + " (phi_pi_data[:,0])])# - Tc0)])\n", + "Nb_valsb = np.array([Nb2b[:,0]/(2*2),\n", + " hotrg_data[:,5],\n", + " phi_pi_data[:,5]])\n", + "Nb_errb = np.array([Nb2b[:,1]/(2*2), hotrg_err, hotrg_err])\n", + "Nb_values_dictb = {'x': Nb_tempsb, 'y': Nb_valsb, 'y_err': Nb_errb}\n", + "fig_labels = np.array([r\"$\\langle N_b^{(2)}\\rangle/V$\", r\"$T_{1111}^{(4)}$\", \n", + " r\"$T_{1111}^{(4)} \\,\\,\\, (\\phi = \\pi/12)$\"])\n", + "x_label = r\"$T$\"# % scale_factor\n", + "#y_label = r\"$\\langle N_b\\rangle/V$\"\n", + "y_label = r\"\"\n", + "labels = {'fig_labels': fig_labels, 'x_label': x_label, 'y_label': y_label}\n", + "limits = {'x_lim': (1., 3.5)}\n", + "Nb_plot_dirb = '../plots/iterated_blocking/bond_stats/Nb_avg/'\n", + "Nb_plot_numb = get_plot_num(Nb_plot_dirb)\n", + "#Nb_plot_fileb = Nb_plot_dirb + str(Nb_plot_numb)\n", + "Nb_plot_numb = get_plot_num('../plots/iterated_blocking/bond_stats/Nb_avg/')\n", + "errorbar_plot(Nb_values_dictb, labels, \n", + " out_file='../plots/iterated_blocking/bond_stats/Nb_avg_hotrg_2_pi_12.png',\n", + " limits=limits, Tc_line=0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "hidden": true + }, + "outputs": [], + "source": [ + "hotrg_err = np.zeros(len(hotrg_data[:,0]))\n", + "Nb_tempsb = np.array([(Nb8b_temps),# - Tc0),\n", + " (hotrg_data[:,0]),# - Tc0),\n", + " (phi_pi_data[:,0])])# - Tc0)])\n", + "Nb_valsb = np.array([Nb8b[:,0]/(8*8),\n", + " hotrg_data[:,3],\n", + " phi_pi_data[:,3]])\n", + "Nb_errb = np.array([Nb8b[:,1]/(8*8), hotrg_err, hotrg_err])\n", + "Nb_values_dictb = {'x': Nb_tempsb, 'y': Nb_valsb, 'y_err': Nb_errb}\n", + "fig_labels = np.array([r\"$\\langle N_b^{(8)}\\rangle/V$\", r\"$T_{1111}^{(0)}$\", \n", + " r\"$T_{1111}^{(\\phi = \\pi/12)}$\"])\n", + "x_label = r\"$(T-T_c)$\"# % scale_factor\n", + "#y_label = r\"$\\langle N_b\\rangle/V$\"\n", + "y_label = r\"\"\n", + "labels = {'fig_labels': fig_labels, 'x_label': x_label, 'y_label': y_label}\n", + "limits = {'x_lim': (1., 3.5)}\n", + "Nb_plot_dirb = '../plots/iterated_blocking/bond_stats/Nb_avg/'\n", + "Nb_plot_numb = get_plot_num(Nb_plot_dirb)\n", + "#Nb_plot_fileb = Nb_plot_dirb + str(Nb_plot_numb)\n", + "Nb_plot_numb = get_plot_num('../plots/iterated_blocking/bond_stats/Nb_avg/')\n", + "errorbar_plot(Nb_values_dictb, labels, out_file='Nb_avg_hotrg_8_pi_12.png',\n", + " limits=limits, Tc_line=0)" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": { + "ExecuteTime": { + "end_time": "2018-02-21T18:29:18.116264Z", + "start_time": "2018-02-21T18:29:15.875604Z" + }, + "hidden": true + }, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Saving file to: Nb_avg_hotrg_8_pi_12.png\n" + ] + }, + { + "data": { + "text/plain": [ + "(,\n", + " )" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "hotrg_err = np.zeros(len(hotrg_data[:,0]))\n", + "Nb_tempsb = np.array([(Nb8b_temps - Tc0),\n", + " (hotrg_data[:,0] - Tc0),\n", + " (phi_pi_data[:,0] - Tc0)])\n", + "Nb_valsb = np.array([Nb8b[:,0]/(8*8),\n", + " hotrg_data[:,3],\n", + " phi_pi_data[:,3]])\n", + "Nb_errb = np.array([Nb8b[:,1]/(8*8), hotrg_err, hotrg_err])\n", + "Nb_values_dictb = {'x': Nb_tempsb, 'y': Nb_valsb, 'y_err': Nb_errb}\n", + "fig_labels = np.array([\"L = 8\", \"1\", \"$\\phi = \\pi/12$\"])\n", + "x_label = r\"$(T-T_c)$\"# % scale_factor\n", + "y_label = r\"$\\langle N_b\\rangle/V$\"\n", + "labels = {'fig_labels': fig_labels, 'x_label': x_label, 'y_label': y_label}\n", + "limits = {'x_lim': (-1.3, 1.15)}\n", + "Nb_plot_dirb = '../plots/iterated_blocking/bond_stats/Nb_avg/'\n", + "Nb_plot_numb = get_plot_num(Nb_plot_dirb)\n", + "#Nb_plot_fileb = Nb_plot_dirb + str(Nb_plot_numb)\n", + "Nb_plot_numb = get_plot_num('../plots/iterated_blocking/bond_stats/Nb_avg/')\n", + "errorbar_plot(Nb_values_dictb, labels, out_file='Nb_avg_hotrg_8_pi_12.png',\n", + " limits=limits, Tc_line=0)" + ] + }, + { + "cell_type": "code", + "execution_count": 124, + "metadata": { + "ExecuteTime": { + "end_time": "2018-02-26T13:03:52.896741Z", + "start_time": "2018-02-26T13:03:48.639874Z" + }, + "hidden": true, + "scrolled": false + }, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Saving file to: ../plots/bond_counts/Nb_avg_hotrg_72.png\n" + ] + } + ], + "source": [ + "Tcs2 = 1./0.39349\n", + "hotrg_temps = np.array([hotrg_data[:,0]]*(hotrg_data.shape[1]-1))\n", + " #for i in range(hotrg_data.shape[1]-1)]).T\n", + "hotrg_errs = np.zeros(hotrg_data[:,1:].T.shape)\n", + "#hotrg_temps -= Tcs2\n", + "hotrg_dict = {'x': hotrg_temps, 'y': hotrg_data[:,1:].T, 'y_err': hotrg_errs}\n", + "hotrg_xlabel = r\"$T - T_c^{(2s)}$\" \n", + "hotrg_ylabel = r\"$\\langle N_b \\rangle / V$\"\n", + "hotrg_labels = {'fig_labels': [r\"$L = 32$\", r\"$L = 16$\", r\"$L = 8$\", \n", + " r\"$L = 4$\", r\"$L = 2$\"],\n", + " 'x_label': hotrg_xlabel, 'y_label': hotrg_ylabel}\n", + "limits = {'x_lim': (-1.5, 0.85)}\n", + "hotrg_plot_dir = '../plots/bond_counts/'\n", + "hotrg_plot_num = get_plot_num(hotrg_plot_dir)\n", + "hotrg_out_file = hotrg_plot_dir + 'Nb_avg_hotrg_{}.png'.format(hotrg_plot_num)\n", + "hotrg_fig, hotrg_ax = errorbar_plot(hotrg_dict, hotrg_labels, hotrg_out_file, \n", + " limits=limits, Tc_line=0)" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": { + "ExecuteTime": { + "end_time": "2018-03-11T00:48:44.704447Z", + "start_time": "2018-03-11T00:48:37.544883Z" + }, + "scrolled": false + }, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Saving file to: ../plots/bond_stats/delta_Nb_all_68.png\n" + ] + } + ], + "source": [ + "#delta_Nb_temps = np.array([Nb64_temps, \n", + "delta_Nb_temps = np.array([Nb32_temps, \n", + " Nb16_temps, \n", + " Nb8_temps,\n", + " Nb4_temps]) - Tc\n", + "#delta_Nb_scale_arr = np.array([2*64*64*np.log(64),\n", + "delta_Nb_scale_arr = np.array([2*32*32*np.log(32),\n", + " 2*16*16*np.log(16),\n", + " 2*8*8*np.log(8),\n", + " 2*4*4*np.log(4)])\n", + "#delta_Nb_vals = np.array([delta_Nb64[:,0], \n", + "delta_Nb_vals = np.array([delta_Nb32[:,0] / delta_Nb_scale_arr[0], \n", + " delta_Nb16[:,0] / delta_Nb_scale_arr[1],\n", + " delta_Nb8[:,0] / delta_Nb_scale_arr[2], \n", + " delta_Nb4[:,0] / delta_Nb_scale_arr[3]])\n", + "#delta_Nb_err = np.array([delta_Nb64[:,1], \n", + "delta_Nb_err = np.array([delta_Nb32[:,1] / delta_Nb_scale_arr[0], \n", + " delta_Nb16[:,1] / delta_Nb_scale_arr[1],\n", + " delta_Nb8[:,1] / delta_Nb_scale_arr[2], \n", + " delta_Nb4[:,1] / delta_Nb_scale_arr[3]])\n", + "delta_Nb_values = {'x': delta_Nb_temps, 'y': delta_Nb_vals, \n", + " 'y_err': delta_Nb_err}\n", + "delta_Nb_xlabel = r\"$T - T_c$\"\n", + "delta_Nb_ylabel = r\"$\\langle \\Delta_{N_b}^2\\rangle / 2V \\log(L)$\"\n", + "#delta_Nb_labels = {'fig_labels': [r\"$L = 64\", \n", + "delta_Nb_labels = {'fig_labels': [r\"$L = 32\", \n", + " r\"$L = 16$\", \n", + " r\"$L = 8$\",\n", + " r\"$L = 4$\"],\n", + " 'x_label': delta_Nb_xlabel, 'y_label': delta_Nb_ylabel}\n", + "delta_Nb_limits = {'x_lim': (-1.3, 1.5)}\n", + "delta_Nb_plot_dir = '../plots/bond_stats/'\n", + "delta_Nb_plot_num = get_plot_num(Nb_plot_dir)\n", + "delta_Nb_out_file = (delta_Nb_plot_dir \n", + " + 'delta_Nb_all_{}.png'.format(delta_Nb_plot_num))\n", + "delta_Nb_fig, delta_Nb_ax = errorbar_plot(delta_Nb_values, \n", + " delta_Nb_labels, delta_Nb_out_file, \n", + " delta_Nb_limits, Tc_line=0)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "ExecuteTime": { + "end_time": "2018-03-10T05:29:30.809613Z", + "start_time": "2018-03-10T05:29:30.469165Z" + }, + "code_folding": [ + 3, + 10, + 17, + 24, + 36, + 38, + 40, + 42 + ], + "collapsed": true, + "run_control": { + "marked": false + } + }, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "text/plain": [ + "Text(0.5,0,'$(T - T_c)L^{0.2029}$')" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "text/plain": [ + "Text(0,0.5,'$\\\\langle \\\\Delta_{N_b}^2\\\\rangle / L^{0.3862}$')" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Saving file to: ../plots/bond_stats/rescaled/delta_Nb_all_rescaled_zoomed_48.png\n" + ] + } + ], + "source": [ + "fig, ax = plt.subplots()\n", + "\n", + "ax.axvline(x=0, linestyle='--', color='k')#, label='$T = T_c$')\n", + "ax.errorbar((Nb32_temps-Tc)*32**(0.2029), delta_Nb32[:,0]/(32*32*32**(0.3862)), \n", + " yerr=delta_Nb32[:,1]/(32*32*32**(1./4)),\n", + " marker='s', color='C0', alpha=1.,\n", + " markersize=4, markeredgecolor='#1f1b93',\n", + " ls='-', fillstyle='full', lw=2,\n", + " elinewidth=2., capsize=2, capthick=2,\n", + " label='L=32')\n", + "ax.errorbar((Nb16_temps-Tc)*16**(0.2029), delta_Nb16[:,0]/(16*16*16**(0.3862)), \n", + " yerr=delta_Nb16[:,1]/(16*16*16**(1./4)),\n", + " marker='H', color='#65e41d',\n", + " markeredgecolor='#00B000', markersize=4., \n", + " lw=2, alpha=1., ls='-', fillstyle='full',\n", + " elinewidth=2., capsize=2, capthick=2,\n", + " label='L=16')\n", + "ax.errorbar((Nb8_temps-Tc)*8**(0.2029), delta_Nb8[:,0]/(8*8*8**(0.3862)), \n", + " yerr=delta_Nb8[:,1]/(8*8*8**(1./4)),\n", + " marker='d', fillstyle='full', color='#be67ff',\n", + " markeredgecolor='#833c9f', markersize=4, \n", + " lw=2, alpha=1., ls='-',\n", + " elinewidth=2., capsize=2, capthick=2,\n", + " label='L=8')\n", + "ax.errorbar((Nb4_temps-Tc)*4**(0.2029), delta_Nb4[:,0]/(4*4*4**(0.3862)), \n", + " yerr=delta_Nb4[:,1]/(4*4*4**(1./4)),\n", + " color='C1', markeredgecolor='#ed4c18', marker='v', \n", + " fillstyle='full', markersize=4, lw=2, \n", + " alpha=1., ls='-',\n", + " elinewidth=2., capsize=2, capthick=2,\n", + " label='L=4')\n", + "\n", + "ax.legend(loc='best', markerscale=1.5, fontsize=14)#, frameon=False)\n", + "#ax.set_xlim(-0.6, 0.6)\n", + "#ax.grid(True)\n", + "ax.set_xlabel('$(T - T_c)L^{0.2029}$', fontsize=16)\n", + "ax.set_ylabel(r\"$\\langle \\Delta_{N_b}^2\\rangle / L^{0.3862}$\", fontsize=16)\n", + "#ax.set_title('Specific Heat Capacity $C_V$ vs. $T$', fontsize=22)\n", + "out_dir = '../plots/bond_stats/rescaled/'\n", + "if not os.path.exists(out_dir):\n", + " os.makedirs(out_dir)\n", + "existing = [int(i.split('_')[-1].rstrip('.png')) for i in os.listdir(out_dir) \n", + " if i.endswith('.png')]\n", + "try:\n", + " latest_num = max(existing)\n", + "except ValueError:\n", + " latest_num = 0\n", + "new_num = latest_num + 1\n", + "out_file = out_dir + 'delta_Nb_all_rescaled_zoomed_{}.png'.format(new_num)\n", + "print(\"Saving file to: {}\".format(out_file))\n", + "plt.savefig(out_file, dpi=600, bbox_inches='tight')\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### $\\langle \\Delta_{N_b}^2\\rangle$ (blocked)" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "ExecuteTime": { + "end_time": "2018-03-10T05:30:16.691173Z", + "start_time": "2018-03-10T05:30:11.433133Z" + }, + "code_folding": [], + "collapsed": true + }, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('