python - matplotlib中的文本框太小
问题描述
我正在尝试使用 matplotlib 在我的情节旁边创建一个文本框。问题是文本框没有完全显示在绘图旁边。即使我最大化地块,也是同样的问题
是否有可能以某种方式调整我的绘图区域并使其更小以便文本框可见,并且即使我最大化地块,面积比也会向前推进
import numpy as np
import time
import matplotlib.pyplot as plt
arr_len = 932826
x = np.random.uniform(low=0, high=4496, size=arr_len)
y = np.random.uniform(low=-74, high=492, size=arr_len)
z = np.random.uniform(low=-30, high=97, size=arr_len)
# Check points
bin_x = 10
bin_y = 10
x1 = np.linspace(x.min(), x.max(), bin_x)
y1 = np.linspace(y.min(), y.max(), bin_y)
def return_val(x, y, z, x1, y1, i, j):
idx = np.logical_and(np.logical_and(x > x1[i - 1], x < x1[i]), np.logical_and(y > y1[j - 1], y < y1[j]))
if np.count_nonzero(idx) == 0:
return np.nan
else:
# print('X range', x[idx].min(), x[idx].max())
# print('Y range', y[idx].min(), y[idx].max())
# print('Z range', z[idx].min(), z[idx].max())
# plt.plot(x[idx], y[idx], '.')
# plt.close()
return np.mean(z[idx])
z1 = np.zeros((len(x1), len(y1)))
for i in range(1, len(x1)):
for j in range(1, len(y1)):
z1[i - 1, j - 1] = return_val(x, y, z, x1, y1, i, j)
z1 = z1.transpose()
fig, ax = plt.subplots()
img = ax.pcolormesh(x1, y1, z1)
# cbar = plt.colorbar(img)
textbox = '\n'.join([
'All plot description goes here: ',
'File Name: ',
'',
'Folder path: ',
'List of big files processed: ',
'Dataset name: ',
'',
'Filter: ',
'Grouping: ',
'Files which are bigger in size than 2000 GB : ',
'',
'...',
'...',
'...',
])
bbox = dict(boxstyle='square', facecolor='lavender', alpha=0.5)
fig.text(1, 1, textbox, fontsize=10, transform=ax.transAxes, bbox=bbox,
verticalalignment='top')
解决方案
推荐阅读
- c++11 - 如何绘制正弦波?
- postgresql - Postgres 将自动增量计数器设置为固定值
- bash - 如何编写while循环以便使用bash完成以下任务?
- javascript - 我在手机和 Windows 上使用此代码检测操作系统时遇到问题
- php - cpanel上传后目标类[App\\Http\\controllers\\AdminAuthController]不存在
- java - 如何纠正 HTTP 状态 500 - Servlet.init() for servlet spring 在 Eclipse IDE 上抛出异常
- material-design - 我想要不同背景颜色的文本字段和 helperText 但它没有发生
- c# - 如何执行对象的批量替换?
- git - git rebase 与分支上的最后一次提交
- c++ - 多个运算符通过操作类型覆盖行为