- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要一个轴宽 80 毫米、高 60 毫米且标签尺寸为 12 磅的图形。图形大小必须严格裁剪,边界框外没有空间。我该怎么做呢?
另外,我想要两个轴以 10 毫米的间距堆叠。我该怎么做?
点是每英寸 72 点或每毫米 72/25.4 点的标准度量。边界框是包含图形所有“墨水”的最小框。
标签尺寸很容易,因为它们以磅为单位定义。根据内容大小固定图形大小很困难。
这个问题的动机是需要创建多个看起来完全相同的出版物质量图。此外,通过 latex 渲染,字符的大小和形状可以与正文完全相同。这也适用于幻灯片演示。所有这些都归结为必须固定为标准单位的每个字体大小的图形大小。
https://en.wikipedia.org/wiki/Point_(typography) :
1 分(排版)=
国际单位制352.78×10−6 m 352.778 μm
美国惯用单位(英制单位)
1.1574×10−3 英尺 13.889×10−3 英寸
最佳答案
你(我)不想要那个。执行此操作的最佳方法是定义以毫米为单位的图形宽度 和 以毫米为单位的轴宽度并将轴 + 标签居中。高度无关紧要,应该针对空白进行修剪。
这只是一个开始,缺少居中。下一步是清理代码并使其成为一个函数(并向菜单添加“修剪高度”和“修剪宽度”按钮)。
基本上这将是一个两步过程。在第一步中,定义了轴的大小,并用标签绘制了图形。在第 2 步中,调用了 tightbox 函数并以英寸为单位计算图形的宽度。然后重新缩放图形并确定新的轴位置。
import matplotlib
import pylab
matplotlib.rc('text', usetex=True)
matplotlib.rc('figure', dpi=72)
font = {'family' : 'normal',
'size' : 10}
matplotlib.rc('font', **font)
matplotlib.rcParams['text.latex.preamble'] = [
r'\usepackage{lmodern}' # latin modern, recommended to replace computer modern sans serif
r'\usepackage{siunitx}', # i need upright \micro symbols, but you need...
r'\sisetup{detect-all}', # ...this to force siunitx to actually use your fonts
r'\usepackage{helvet}', # set the normal font here
r'\usepackage{sansmath}', # load up the sansmath so that math -> helvet
r'\sansmath'] # <- tricky! -- gotta actually tell tex to use!
matplotlib.rcParams['xtick.major.pad'] = 3 # ticklabel spacing between axis and text
matplotlib.rcParams['ytick.major.pad'] = 2 #
# APS, PRL, Two Columns
column_width_mm = 86.4581 #mm
column_height_mm = 2.5*column_width_mm
fig_hspace_mm = 10 # mm
fig_wspace_mm = 10 # mm
axis_width_mm = 69.16648
axis_height_mm = 43.09763
column_width_inch = column_width_mm/25.4
column_height_inch = column_height_mm/25.4
trim_height_below_mm = 0.0
trim_height_above_mm = 0.0
pylab.figure(num = 1, figsize=(column_width_inch, column_height_inch))
ax_0 = pylab.axes([fig_wspace_mm/column_width_mm, (1.0*fig_hspace_mm + 0.0*axis_height_mm)/column_height_mm, axis_width_mm/column_width_mm, axis_height_mm/column_height_mm])
ax_1 = pylab.axes([fig_wspace_mm/column_width_mm, (2.0*fig_hspace_mm + 1.0*axis_height_mm)/column_height_mm, axis_width_mm/column_width_mm, axis_height_mm/column_height_mm])
ax_2 = pylab.axes([fig_wspace_mm/column_width_mm, (3.0*fig_hspace_mm + 2.0*axis_height_mm)/column_height_mm, axis_width_mm/column_width_mm, axis_height_mm/column_height_mm])
ax_3 = pylab.axes([fig_wspace_mm/column_width_mm, (4.0*fig_hspace_mm + 3.0*axis_height_mm)/column_height_mm, axis_width_mm/column_width_mm, axis_height_mm/column_height_mm])
ax_0.set_position([fig_wspace_mm/column_width_mm, (1.0*fig_hspace_mm + 0.0*axis_height_mm - trim_height_below_mm)/column_height_mm, axis_width_mm/column_width_mm, axis_height_mm/column_height_mm])
ax_1.set_position([fig_wspace_mm/column_width_mm, (2.0*fig_hspace_mm + 1.0*axis_height_mm - trim_height_below_mm)/column_height_mm, axis_width_mm/column_width_mm, axis_height_mm/column_height_mm])
ax_2.set_position([fig_wspace_mm/column_width_mm, (3.0*fig_hspace_mm + 2.0*axis_height_mm - trim_height_below_mm)/column_height_mm, axis_width_mm/column_width_mm, axis_height_mm/column_height_mm])
ax_3.set_position([fig_wspace_mm/column_width_mm, (4.0*fig_hspace_mm + 3.0*axis_height_mm - trim_height_below_mm)/column_height_mm, axis_width_mm/column_width_mm, axis_height_mm/column_height_mm])
###########################
# plot figure here
###########################
pylab.sca(ax_0)
pylab.xlabel(r'$\mathrm{10pt~Test~Label~with~huge~symbols:}~\int~~\mathrm{[\frac{m}{s}]}$')
###########################
fig = pylab.gcf()
old_size = fig.get_size_inches()
old_width_mm = old_size[0]*25.4
old_height_mm = old_size[1]*25.4
bbox3 = ax_3.get_tightbbox(pylab.gcf().canvas.get_renderer())
bbox0 = ax_0.get_tightbbox(pylab.gcf().canvas.get_renderer())
trim_height_below_mm = ((bbox0.ymin)/72.0*25.4)
trim_height_above_mm = old_height_mm - ((bbox3.ymax+4)/72.0*25.4)
new_size = fig.get_size_inches()
new_width_mm = new_size[0]*25.4
new_height_mm = new_size[1]*25.4 - trim_height_below_mm - trim_height_above_mm
fig.set_size_inches(new_width_mm/25.4, new_height_mm/25.4, num = 1, forward=True)
print new_size, old_size, new_width_mm, new_height_mm
print trim_height_below_mm, trim_height_above_mm
column_width_mm = new_width_mm
column_height_mm = new_height_mm
ax_0.set_position([fig_wspace_mm/column_width_mm, (1.0*fig_hspace_mm + 0.0*axis_height_mm - trim_height_below_mm)/column_height_mm, axis_width_mm/column_width_mm, axis_height_mm/column_height_mm])
ax_1.set_position([fig_wspace_mm/column_width_mm, (2.0*fig_hspace_mm + 1.0*axis_height_mm - trim_height_below_mm)/column_height_mm, axis_width_mm/column_width_mm, axis_height_mm/column_height_mm])
ax_2.set_position([fig_wspace_mm/column_width_mm, (3.0*fig_hspace_mm + 2.0*axis_height_mm - trim_height_below_mm)/column_height_mm, axis_width_mm/column_width_mm, axis_height_mm/column_height_mm])
ax_3.set_position([fig_wspace_mm/column_width_mm, (4.0*fig_hspace_mm + 3.0*axis_height_mm - trim_height_below_mm)/column_height_mm, axis_width_mm/column_width_mm, axis_height_mm/column_height_mm])
pylab.show()
关于python - 如何在 matplotlib 中以毫米为单位设置轴尺寸和位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33239243/
我有 2 张 table ; item_in(item_id,unit) item_out(item_id,unit) 现在假设我想知道为每个项目插入了多少个单元,我只是查询 select sum(u
API 浏览器中有 3 个速率限制类别: 如果我使用 Youtube 数据 API(其中跟随 implicit OAuth grant flow)创建客户端 Web 应用程序,我是否仍被限制为总共 1
我正在使用一个 postgresql 表,该表包含许多带有 GEOMETRY(Point, 4326) 的行。使用 ST_SnapToGrid 函数和 DISTINCT 选择,我只根据显示的 map
我对 C++ 和 Cppunit 都很陌生。我正在尝试编译一个小的 cppunit 测试。但是,我没有成功。 qwerty@qwerty:~/chessgame/src$ g++ -Wall Coor
我注意到 REM 单位可用于元素的大小,而不仅仅是字体大小。并且对 HTML 字体大小属性非常有用。 html { font-size:1vw } @media all and (max-width:
我试图在 Shapely 中找到线串的长度(以米为单位),但似乎无法达到预期的结果。几乎可以肯定我在坐标系方面犯了一些错误,但我无法弄清楚。 这是单行的一些简化代码: from shapely.geo
对于大量的物种数据集,我试图计算给定月份集的圆形平均值,例如对于从 3 月到 7 月开花的物种,我想知道开花的平均月份(即 5 月),以及围绕平均值的方差。 给定月份是循环的,因此 12 月到 2 月
我还应该在单元测试中释放对象吗? 我注意到在Apple的“iPhoneUnitTests”示例项目中,设置方法中的对象是[[object alloc] init],但从未在单元测试中的任何地方发布?
我目前正在使用 OpenGL 进行开发,并使用米作为我自己的单位,即 20 厘米宽的三角形为 0.2。然而 OpenGL 似乎对这些数字进行了舍入,最终的形状并不完全符合我的意愿。这在 OpenGL
我的问题与对信号进行频谱分析或将信号放入 FFT 并使用合适的数值包解释结果的物理意义有关, 具体: 获取一个信号,例如时变电压 v(t) 将其放入 FFT 中(您将得到复数序列) 现在取模 (abs
在深入研究代码后,我意识到 Fabricjs Text 对象的 fontSize 是在 PIXELS 中测量的。在我的项目中,有时我需要使用点而不是像素。 当指定单位时,我只在代码中找到一个位置,此片
在我的应用程序中,我尝试使用,RentModel.find({prop_location : { $near : [msg.lat, msg.lng],$maxDistance : 500}},函数(
我正在开发我的第一个 LibGdx (Scene2d + Box2d) 游戏,这对我来说是一个全新的领域,但仍然对一些事情感到有点困惑,尤其是关于单位。已经看到了几种不同的处理方法,但仍然不确定哪种方
我正在寻找一个 MySQL 查询(子查询很好),它将以下列格式获取过去一年中每个订单的单位分布: units_per_order | number_of_orders |
我正在使用 Highcharts生成折线图。 我遇到了 numberFormat 的问题: var test = 15975000; numberFormat(test, 0,',','.'); 结果
我正在尝试创建一些用户定义的类型来表示单位,以便我可以强类型化函数参数。例如,长度为毫米,速度为毫米每秒,加速度为毫米每秒等。 到目前为止我已经这样做了: template struct Value
谁能解释一下最低精度的 ULP 单位?我有如下定义,但还是不清楚 “表示分数时的误差大小与存储的数字大小成正比。ULP 或最小精度单位定义了存储数字时可以获得的最大误差。存储的数字越大,ULP 越大”
我有一张卡片图像,我需要重复它 30 次,每次我想申请一张特定卡片的左侧位置时,它会与卡片重叠,然后再停留在一副牌的位置上。 问题是,当我将左侧位置应用于图像卡片时,它会将相同的左侧位置应用于所有卡片
有没有办法用php代码更改每个滚动条的大小。 说明:当我向下滚动时,它会下降x(50~)像素,我想将x改为20。 编辑:这是我的代码。。。 Excel "; $i=1; wh
我不知道下面的想法是否可行或不能概括它,但我想将每个计算值四舍五入到 100 单位四舍五入。 例子: double x; int x_final; ... if (x<400) x_final=400
我是一名优秀的程序员,十分优秀!