matplotlib figures scale weirdly / can't get a nice small figure
- 主要言語
- Python
- スター
- 734
- フォーク
- 412
- 平均マージ
- 1日 5時間
- マージ済み PR(30日)
- 8
説明
I'm using Jupyter notebook with anaconda and yesterday updated ipykernel (from I think 4.3.x to 4.6.1).
Before, when I plotted something, by default I got a fairly small figure like below:
Suddenly, the figures now are really big (by default take up the whole width of the browser) and I can't really scale them down, at least not in a pretty way. I'm using `%matplotlib inline` and for example when I specify `plt.rcParams['figure.figsize'] = (10,6)` I get a nice large figure as below:
However, if I'm trying to make the figure smaller, e.g. with `plt.rcParams['figure.figsize'] = (2,1.2)`, while I do get a smaller figure, it looks awful as it doesn't scale accordingly:

the code that's used to generate the figures is the following:
```
def plot_mnist(X, y, X_test=None, y_test=None, title=None):
plt.figure()
colorlist = get_colors(10)
# Scale and visualize the embedding vectors
x_min, x_max = np.min(X, 0), np.max(X, 0)
if (X_test is not None) and (y_test is not None):
x_min, x_max = np.min(np.array([x_min, np.min(X_test, 0)]), 0), np.max(np.array([x_max, np.max(X_test, 0)]), 0)
X_test = (X_test - x_min) / (x_max - x_min)
X = (X - x_min) / (x_max - x_min)
if (X_test is not None) and (y_test is not None):
for i in range(X_test.shape[0]):
plt.text(X_test[i, 0], X_test[i, 1], str(y_test[i]),
color=colorlist[y_test[i]],
fontdict={'weight': 'medium', 'size': 'smaller'},
alpha=0.4)
for i in range(X.shape[0]):
plt.text(X[i, 0], X[i, 1], str(y[i]),
color=colorlist[y[i]],
fontdict={'weight': 'medium', 'size': 'smaller'},
alpha=1.)
plt.xticks([]), plt.yticks([])
plt.xlim(-0.05, 1.05)
plt.ylim(-0.05, 1.05)
if title is not None:
plt.title(title)
```
Since the figures scale nicely when I decrease the width of the browser window, I'm assuming the nice way to specify the size of the figures would be to tell the notebook how much of the default width of the browser window it should use for the figure but I'm not sure if or where I could find such a setting?
I guess it might be nice if such a matplotlib inline specification would also be independent of the actual figure size, as I might want to have a large figure to save it in high quality somewhere else but then still only display a smaller figure in the notebook.
コントリビューションガイド
調査の方向性
Reproduce the issue in a Jupyter notebook with `%matplotlib inline`, ipykernel 4.6.1, and the provided plotting function, comparing default sizing with `figure.figsize` values of (10,6) and (2,1.2). No repository files or tests are named; done means small figures retain proportional, readable rendering while larger figures can still be used for output.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- anaconda, jupyter-notebook, matplotlib, python
- 領域
- data-visualization, tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100