Python matplotlib figure size

matplotlib におけるサイズ(inch, dpi)を調べる方法。

 


fig = pyplot.gcf()
size = fig.get_size_inches()*fig.dpi
print(fig.dpi)
print(fig.get_size_inches())

---

72.0
[ 6. 4.]

++++++

逆にこれらを設定したいときは

pyplot.rcParams['figure.dpi'] = 72 #80 -default
pyplot.rcParams['savefig.dpi'] = 72 #80 -default
pyplot.rcParams['figure.figsize'] = [6,4] # [8.0, 6.0] -default

のようにする。

symbolic linkをはる

$ ps2pdf 20171123_paper.ps
dyld: Library not loaded: /opt/local/lib/libgs.9.22.dylib
Referenced from: /opt/local/bin/gs
Reason: image not found
Abort trap: 6

と突然ライブラリが使えなくなった。調べると、ライブラリがアップデートされている。

 

$ ls -l /opt/local/lib/libgs.*
-rwxr-xr-x 1 root wheel 11779832 Mar 26 00:29 /opt/local/lib/libgs.9.23.dylib*
lrwxr-xr-x 1 root wheel 16 Mar 26 00:29 /opt/local/lib/libgs.9.dylib@ -> libgs.9.23.dylib
lrwxr-xr-x 1 root wheel 16 Mar 26 00:29 /opt/local/lib/libgs.dylib@ -> libgs.9.23.dylib

 

そこで、シンボリック・リンクをはる。

$ sudo ln -s /opt/local/lib/libgs.9.23.dylib /opt/local/lib/libgs.9.22.dylib 

 

$ ls -l /opt/local/lib/libgs.*
lrwxr-xr-x 1 root wheel 31 Mar 26 01:23 /opt/local/lib/libgs.9.22.dylib@ -> /opt/local/lib/libgs.9.23.dylib
-rwxr-xr-x 1 root wheel 11779832 Mar 26 00:29 /opt/local/lib/libgs.9.23.dylib*
lrwxr-xr-x 1 root wheel 16 Mar 26 00:29 /opt/local/lib/libgs.9.dylib@ -> libgs.9.23.dylib
lrwxr-xr-x 1 root wheel 16 Mar 26 00:29 /opt/local/lib/libgs.dylib@ -> libgs.9.23.dylib

tensorflow installation


Following

https://www.tensorflow.org/install/install_mac

and some advice on pip written at

https://github.com/certbot/certbot/issues/2850

I installed tensorflow:

 

$ pip uninstall virtualenv
$ conda install virtualenv

 

Here I use " ~/tensorflow" as the target directory.


$ virtualenv --system-site-packages ~/tensorflow

$ cd ~/tensorflow
$ source ./bin/activate

(tensorflow) kohei:tensorflow khattori$
(tensorflow) kohei:tensorflow khattori$ easy_install -U pip
(tensorflow) kohei:tensorflow khattori$ pip install --upgrade tensorflow
(tensorflow) kohei:tensorflow khattori$

 

schwimmbad インストール

$ conda install -c conda-forge schwimmbad
Solving environment: done


==> WARNING: A newer version of conda exists. <==
current version: 4.4.8
latest version: 4.4.10

Please update conda by running

$ conda update -n base conda

 

## Package Plan ##

environment location: /Users/_my_user_name_/anaconda

added / updated specs:
- schwimmbad


The following packages will be downloaded:

package | build
---------------------------|-----------------
certifi-2018.1.18 | py27_0 143 KB conda-forge
schwimmbad-0.2.1 | py27_0 15 KB conda-forge
openssl-1.0.2n | 0 3.3 MB conda-forge
ca-certificates-2018.1.18 | 0 141 KB conda-forge
conda-4.3.34 | py27_0 507 KB conda-forge
------------------------------------------------------------
Total: 4.1 MB

The following NEW packages will be INSTALLED:

ca-certificates: 2018.1.18-0 conda-forge
schwimmbad: 0.2.1-py27_0 conda-forge

The following packages will be UPDATED:

certifi: 2017.11.5-py27_0 conda-forge --> 2018.1.18-py27_0 conda-forge
openssl: 1.0.2j-0 --> 1.0.2n-0 conda-forge

The following packages will be DOWNGRADED:

conda: 4.4.8-py27_0 anaconda --> 4.3.34-py27_0 conda-forge

Proceed ([y]/n)? y


Downloading and Extracting Packages
certifi 2018.1.18: ################################################################################################ | 100%
schwimmbad 0.2.1: ################################################################################################# | 100%
openssl 1.0.2n: ################################################################################################### | 100%
ca-certificates 2018.1.18: ######################################################################################## | 100%
conda 4.3.34: ##################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

install mpi4py on MacPro

Anacondaを使って、Mac Pro にmpi4pyをインストール。

 

$ conda install -c anaconda mpi4py
Fetching package metadata ...............
Solving package specifications: .

Package plan for installation in environment /Users/_my_username_/anaconda:

The following NEW packages will be INSTALLED:

mpi4py: 2.0.0-py27_0 anaconda
openmpi: 1.6.3-1 anaconda

The following packages will be UPDATED:

conda: 4.3.29-py27_0 conda-forge --> 4.4.8-py27_0 anaconda
pycosat: 0.6.1-py27_1 --> 0.6.3-py27h6c51c7e_0 anaconda

The following packages will be SUPERSEDED by a higher-priority channel:

conda-env: 2.6.0-0 conda-forge --> 2.6.0-h36134e3_0 anaconda

Proceed ([y]/n)? y

conda-env-2.6. 100% |###########################################################################| Time: 0:00:00 1.66 MB/s
openmpi-1.6.3- 100% |###########################################################################| Time: 0:00:00 10.75 MB/s
mpi4py-2.0.0-p 100% |###########################################################################| Time: 0:00:00 23.69 MB/s
pycosat-0.6.3- 100% |###########################################################################| Time: 0:00:00 4.53 MB/s
conda-4.4.8-py 100% |###########################################################################| Time: 0:00:00 5.07 MB/s

 

$ python

Python 2.7.12 |Anaconda custom (x86_64)| (default, Jul 2 2016, 17:43:17)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import mpi4py
>>>