ipython / ipython/ipykernel

matplotlib figures scale weirdly / can't get a nice small figure

Đang mở
#279 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
734
Fork
412
Merge trung bình
1 ngày 5 giờ
Pull request đã merge (30 ngày)
8

Mô tả

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:
fig_before
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:
fig_10_6
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:
fig_2_12

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.