- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想以精确的分辨率(例如 800x600)绘制图表,但使用 bbox_inches='tight
' 时,绘图不是全分辨率,而是较小。我可以手动将图像尺寸(以英寸为单位)设置为大约(9.2,6.5),结果为799 x 601,但我希望有更好的解决方案。可以在调整尺寸之前设置bbox_inches='tight'
吗?
import matplotlib as mlp
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111)
x = y = np.arange(0, 1, 0.1)
plt.plot(x, y, label='my function')
plt.title('title')
ax.set_xlabel('xAxis')
ax.set_ylabel('yAxis')
#print fig.get_size_inches()
#fig.set_size_inches(9.2, 6.5)
plt.savefig('exact_size_test.png', bbox_inches='tight', dpi=100)
最佳答案
您想使用tight_layout
(doc)在调用 savefig
import matplotlib as mlp
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111)
x = y = np.arange(0, 1, 0.1)
plt.plot(x, y, label='my function')
plt.title('title')
ax.set_xlabel('xAxis')
ax.set_ylabel('yAxis')
#print fig.get_size_inches()
fig.set_size_inches(8, 6, forward=True)
fig.tight_layout()
plt.savefig('exact_size_test.png', dpi=100)
关于python - 在 matplotlib 中使用 bbox_inches ='tight' 时,如何获得具有精确大小(以像素为单位)的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15141944/
我有一个数据文件,我想创建一个 pm3d map 点阵。代码: set term pngcairo size 800,600 set out "test.png" set pm3d map splot
这句话我听过很多次了。这是什么意思? 举个例子会有所帮助。 最佳答案 来自Wiktionary : (计算)在汇编语言中,包含少量指令并迭代多次的循环。 (计算)此类循环大量使用 I/O 或处理资源,
具有键/值对“紧密”重复模式的字符串(对于此示例,键是“name”,值应该是单个小写单词) string text = "name: abc name: def name: ghi name: jkl
这是我的 HTML 的结构: Some text Not much text Some text Not much text Some text Not much text 我有三个
我经常使用 matplotlib 生成单个图形,这些图形应该垂直或水平对齐,例如在 LaTeX 文档中。我的目标是: 避免在所有图中留出过多的边距或剪裁。对于独立图形,这可以通过使用 bbox_inc
好的,所以我在这里被观察者模式困住了,我读过的几乎所有教程都告诉主题类订阅观察者。 但是考虑到封装,这怎么能不紧密耦合呢?他们仍然相互依赖,不是吗? 我的意思是,subject Class必须知道观察
根据documentation , ax.autoscale(tight=True) 应该 If True, set view limits to data limits; 与 ax.axis('ti
似乎 savefig 中的 bbox_inches='tight' 选项忽略了没有文本的注释。这是我的示例代码 import matplotlib.pyplot as plt fig = plt.fi
我正在尝试创建我的网页,但我遇到了 float 问题。 这是我的 HTML 代码: InformacjeAutokoder.pl jest obecnie najbardziej innowa
我有一个程序可以将其进度打印到控制台。每 20 步,它会打印步数,例如 10 20 30 等,但在此范围内,它会打印一个点。这是使用末尾带有逗号的 print 语句打印的 (python 2.x)
当您在 Matplotlib 的 savefig() 函数中设置 bbox_inches = 'tight' 时,它会尝试找到封装图形窗口中所有内容的最紧密的边界框。不幸的是,最紧密的边界框似乎包含不
我在 ipython 笔记本中使用以下代码将条形图保存为 .png 文件: plt.savefig(文件名, bbox_inches='tight') 它在我的电脑上运行,我试过在另一台电脑上运行脚本
我必须绘制一个矢量图,我只想看到没有轴、标题等的矢量,所以我尝试这样做: pyplot.figure(None, figsize=(10, 16), dpi=100) pyplot.quiver(da
你能给我解释一下下面的短语(摘自 an answer to Stack Overflow question What are the differences between Deferred, Pro
我正在开发一个 WordPress 插件,并努力确保最佳实践。我有两个类,我的插件类“Jargonaut”是必需的,然后是另一个名为“Dictionary”的类,它随 require_once() 包
我一点也不擅长设计,我只是想在 Bootstrap 4 中进行简单的表单对齐;我根本没有做任何定制,只是很乐意接受框架给我的任何东西。 我已经通读了表单文档,变体的数量非常困惑,到目前为止,我尝试的一
我在尝试通过我的数据拟合平均曲线以求出长度时遇到了问题。我在一个 Pandas 数据框中有很多 X、Y 点,看起来像这样: x = np.asarray([731501.13, 731430.24,
我下载了 Enhanced Tight VNC Viewer ( http://www.karlrunge.com/x11vnc/ssvnc.html ) 并按照说明将我本地机器(运行 Win 7)上
本文整理了Java中com.sun.msv.datatype.xsd.WhiteSpaceProcessor.tightness()方法的一些代码示例,展示了WhiteSpaceProcessor.t
我正在制作一个嵌入 latex 中的出版物质量图,我希望在大小和字体方面非常精确(以便文章中的字体与图中的字体大小相同)。为了防止绘图在 latex 中缩放,我想要它的确切尺寸,但我不能。这是我的代码
我是一名优秀的程序员,十分优秀!