Pythonista3 Matplotlib style

提供:yonewiki

Pythonista3に戻る

matplotlibの*.mplstyleによるstyle適用

Pythonista3では、初期状態では5つのstyleセットが準備されています。最新版では20を超えるセットが用意されています。styleセットは*.mplstyleファイルによって定義して追加できますが、pythonista3では簡単にstyleセットが増やすことは出来ないため、その手順を以下に示します。


1.stashを導入する。

 対話型コマンドで以下のような命令文を実行することでstashが導入できる。

 import requests as r; exec(r.get('http://bit.ly/get-stash').text)

 上記のコマンドによりpythonista3のthis iPadフォルダにlaunch.pyというファイルが作成され、このpyファイルを実行することでコンソールViewよりstashにて提供されるシェルコマンドが実行できるようになる。


2.”mplstyleファイルをpythonista3でpython module>site-package-3>matplotlib>stylelibに作成する。ここではexample.mplstyleとします。


3.stashで以下のようなコマンドを実行する

cd site-package-3/matplotlib/stylelib
cp example.mplestyle ~/.matplotlib/stylelib/

matplotlib version1.4.0のstyleキー一覧

最新版よりversion1.4.0の方がstyleキーは少ないです。


例えば

 axes.prop_cycleというキーは使えないため、それに対応するキーはaxes.color_cycleとなります。

 対応するとはいえ機能は異なり、使い方が違います。prop_cycleでは


cycler()


 という関数で定義し、RGB_hex_value_xというのがffffffのような16進数カラーコードや赤ならrもしくはredというようなカラーキーワードならば


例えば

 axes.prop_cycleというキーは使えないため、それに対応するキーはaxes.color_cycleとなります。

 対応するとはいえ機能は異なり、使い方が違います。prop_cycleでは


cycler()


 という関数で定義し、RGB_hex_value_xというのがffffffのような16進数カラーコードや赤ならrもしくはredというようなカラーキーワードならばaxes.prop_cycleというキーワードに対しては


axes.prop_cycle : cycler(color=[‘RGB_hex_value_1’, ..., ‘RGB_hex_value_n’],line=[‘line_style_marker_simbol’]))


 という形式で、[]内はオプションの設定です。色とマーカーシンボルの形を同時に指定出来ます。このような複数の色を順番に使って行く形式で色を設定出来るキーワードは幾つかあります。グラフの色に統一感を与えるならば必須の設定だと思います。マーカーシンボルは'-'とか'--'のようなシンボル用のキーワードが入ります。別にカラーと対になっている必要もないです。Styleが指定値で繰り返されるだけです。


color_cycleはシングルクォートも使わず 

axes.prop_cycle : RGB_hex_value_1, RGB_hex_value_2, ..., RGB_hex_value_nという値を設定します。

 このように使えるキーが異なることに注意が必要です。


 利用できるキーは以下のようなものです。これはデフォルトで設定されている内容。もうちょっと設定できるキーやパラメータあります。


値はデフォルト値

font.size: 12
font.stretch: normal
font.style: normal
font.variant: normal
font.weight: normal
grid.alpha: 1.0
grid.color: k
grid.linestyle: :
grid.linewidth: 0.5
image.aspect: equal
image.cmap: jet
image.interpolation: bilinear
image.lut: 256
image.origin: upper
image.resample: False
interactive: False
keymap.all_axes: a
keymap.back: ['left', 'c', 'backspace']
keymap.forward: ['right', 'v']
keymap.fullscreen: ('f', 'ctrl+f')
keymap.grid: g
keymap.home: ['h', 'r', 'home']
keymap.pan: p
keymap.quit: ('ctrl+w', 'cmd+w')
keymap.save: ('s', 'ctrl+s')
keymap.xscale: ['k', 'L']
keymap.yscale: l
keymap.zoom: o
legend.borderaxespad: 0.5
legend.borderpad: 0.4
legend.columnspacing: 2.0
legend.fancybox: False
legend.fontsize: large
legend.frameon: True
legend.handleheight: 0.7
legend.handlelength: 2.0
legend.handletextpad: 0.8
legend.isaxes: True
legend.labelspacing: 0.5
legend.loc: upper right
legend.markerscale: 1.0
legend.numpoints: 2
legend.scatterpoints: 3
legend.shadow: False
lines.antialiased: True
lines.color: b
lines.dash_capstyle: butt
lines.dash_joinstyle: round
lines.linestyle: -
lines.linewidth: 1.0
lines.marker: None
lines.markeredgewidth: 0.5
lines.markersize: 6
lines.solid_capstyle: projecting
lines.solid_joinstyle: round
mathtext.bf: serif:bold
mathtext.cal: cursive
mathtext.default: it
mathtext.fallback_to_cm: True
mathtext.fontset: cm
mathtext.it: serif:italic
mathtext.rm: serif
mathtext.sf: sans\-serif
mathtext.tt: monospace
patch.antialiased: True
patch.edgecolor: k
patch.facecolor: b
patch.linewidth: 1.0
path.effects: []
path.simplify: True
path.simplify_threshold: 0.1111111111111111
path.sketch: None
path.snap: True
pdf.compression: 6
pdf.fonttype: 3
pdf.inheritcolor: False
pdf.use14corefonts: False
pgf.debug: False
pgf.preamble: ['']
pgf.rcfonts: True
pgf.texsystem: xelatex
plugins.directory: .matplotlib_plugins
polaraxes.grid: True
ps.distiller.res: 6000
ps.fonttype: 3
ps.papersize: letter
ps.useafm: False
ps.usedistiller: False
savefig.bbox: None
savefig.directory: ~
savefig.dpi: 100
savefig.edgecolor: w
savefig.extension: png
savefig.facecolor: w
savefig.format: png
savefig.frameon: True
savefig.jpeg_quality: 95
savefig.orientation: portrait
savefig.pad_inches: 0.1
savefig.transparent: False
svg.embed_char_paths: True
svg.fonttype: path
svg.image_inline: True
svg.image_noscale: False
text.antialiased: True
text.color: k
text.dvipnghack: None
text.hinting: True
text.hinting_factor: 8
text.latex.preamble: ['']
text.latex.preview: False
text.latex.unicode: False
text.usetex: False
timezone: UTC
tk.pythoninspect: False
tk.window_focus: False
toolbar: toolbar2
verbose.fileo: sys.stdout
verbose.level: silent
webagg.open_in_browser: True
webagg.port: 8988
webagg.port_retries: 50
xtick.color: k
xtick.direction: in
xtick.labelsize: medium
xtick.major.pad: 4
xtick.major.size: 4
xtick.major.width: 0.5
xtick.minor.pad: 4
xtick.minor.size: 2
xtick.minor.width: 0.5
ytick.color: k
ytick.direction: in
ytick.labelsize: medium
ytick.major.pad: 4
ytick.major.size: 4
ytick.major.width: 0.5
ytick.minor.pad: 4
ytick.minor.size: 2
ytick.minor.width: 0.5

Pythonista3に戻る