- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要一个方向性图来分析/呈现我的测量数据。从 -90° 到 90° 的角度(0° 必须显示为北),右值也应该可以为负(dB 刻度)。
我试过了 奥 git _a目前我使用 Floating axis example 中的fractional_polar_axes() 。很好的代码,但我不明白。但我仍然不知道如何让它达到我的目的。我还是个菜鸟,我找不到合适的(简单的)解决方案。
如果我尝试将 rlimits 设置为 (-20,0) python (spyder) 崩溃。
如果我尝试将 theta 设置为 (-90,90),它可以工作,但它旋转了 90 度,我需要 0 到北而不是东。我尝试添加额外的旋转角度,但我不明白该怎么做。所有尝试都失败了。
这里我将一个示例放在一个文件中。
"""Demo of polar plot of arbitrary theta. This is a workaround for MPL's polar plot limitation
to a full 360 deg.
Based on http://matplotlib.org/mpl_toolkits/axes_grid/examples/demo_floating_axes.py
"""
from __future__ import division
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.transforms import Affine2D
from matplotlib.projections import PolarAxes
from mpl_toolkits.axisartist import angle_helper
from mpl_toolkits.axisartist.grid_finder import MaxNLocator
from mpl_toolkits.axisartist.floating_axes import GridHelperCurveLinear, FloatingSubplot
def fractional_polar_axes(f, thlim=(0, 180), rlim=(0, 1), step=(30, 0.2),
thlabel='theta', rlabel='r', ticklabels=True):
"""Return polar axes that adhere to desired theta (in deg) and r limits. steps for theta
and r are really just hints for the locators."""
th0, th1 = thlim # deg
r0, r1 = rlim
thstep, rstep = step
# scale degrees to radians:
tr_scale = Affine2D().scale(np.pi/180., 1.)
tr = tr_scale + PolarAxes.PolarTransform()
theta_grid_locator = angle_helper.LocatorDMS((th1-th0)//thstep)
r_grid_locator = MaxNLocator((r1-r0)//rstep)
theta_tick_formatter = angle_helper.FormatterDMS()
grid_helper = GridHelperCurveLinear(tr,
extremes=(th0, th1, r0, r1),
grid_locator1=theta_grid_locator,
grid_locator2=r_grid_locator,
tick_formatter1=theta_tick_formatter,
tick_formatter2=None)
a = FloatingSubplot(f, 111, grid_helper=grid_helper)
f.add_subplot(a)
# adjust x axis (theta):
a.axis["bottom"].set_visible(False)
a.axis["top"].set_axis_direction("bottom") # tick direction
a.axis["top"].toggle(ticklabels=ticklabels, label=bool(thlabel))
a.axis["top"].major_ticklabels.set_axis_direction("top")
a.axis["top"].label.set_axis_direction("top")
# adjust y axis (r):
a.axis["left"].set_axis_direction("bottom") # tick direction
a.axis["right"].set_axis_direction("top") # tick direction
a.axis["left"].toggle(ticklabels=ticklabels, label=bool(rlabel))
# add labels:
a.axis["top"].label.set_text(thlabel)
a.axis["left"].label.set_text(rlabel)
# create a parasite axes whose transData is theta, r:
auxa = a.get_aux_axes(tr)
# make aux_ax to have a clip path as in a?:
auxa.patch = a.patch
# this has a side effect that the patch is drawn twice, and possibly over some other
# artists. So, we decrease the zorder a bit to prevent this:
a.patch.zorder = -2
# add sector lines for both dimensions:
thticks = grid_helper.grid_info['lon_info'][0]
rticks = grid_helper.grid_info['lat_info'][0]
for th in thticks[1:-1]: # all but the first and last
auxa.plot([th, th], [r0, r1], '--', c='grey', zorder=-1)
for ri, r in enumerate(rticks):
# plot first r line as axes border in solid black only if it isn't at r=0
if ri == 0 and r != 0:
ls, lw, color = 'solid', 2, 'black'
else:
ls, lw, color = 'dashed', 1, 'grey'
# From http://stackoverflow.com/a/19828753/2020363
auxa.add_artist(plt.Circle([0, 0], radius=r, ls=ls, lw=lw, color=color, fill=False,
transform=auxa.transData._b, zorder=-1))
return auxa
# my own code
#import numpy as np
#import polar_demo
theta =np.arange(-90., 91, 1)
v = np.array([0.003029756, 0.003278999, 0.003891915, 0.003397707, 0.004088546, 0.004237963, 0.004576779, 0.005137577, 0.005557515, 0.006002701, 0.006251121, 0.006115849, 0.006220946, 0.006702619, 0.006487209, 0.006965977, 0.006961644, 0.006344132, 0.006135627, 0.005891294, 0.005498547, 0.005860019, 0.005952021, 0.005632097, 0.006041763, 0.006388289, 0.005938246, 0.006262405, 0.006516638, 0.006149105, 0.006040157, 0.005713938, 0.004380804, 0.003073705, 0.002339913, 0.002011604, 0.002419609, 0.002411165, 0.002088174, 0.002099459, 0.003443293, 0.004828490, 0.005701596, 0.006000785, 0.007054744, 0.007375258, 0.007692269, 0.007849744, 0.007883301, 0.008043624, 0.007892837, 0.008227520, 0.008790336, 0.009058158, 0.008707412, 0.008264507, 0.007942288, 0.007729781, 0.007153670, 0.006177770, 0.005930654, 0.006878120, 0.008224512, 0.009333521, 0.009887548, 0.010679240, 0.012035168, 0.013572552, 0.014649003, 0.016023062, 0.017153479, 0.017482565, 0.016855999, 0.016556822, 0.017210254, 0.018402022, 0.020348028, 0.022555166, 0.024685826, 0.026662607, 0.030263813, 0.034134498, 0.037835099, 0.041901713, 0.045083964, 0.047717820, 0.050501022, 0.052132071, 0.053025513, 0.054776115, 0.054434939, 0.053598260, 0.052045371, 0.049853666, 0.047209907, 0.043862515, 0.040879899, 0.038089268, 0.034993134, 0.032141467, 0.028673013, 0.025357649, 0.021715866, 0.018649413, 0.016134787, 0.016080060, 0.016607230, 0.017332138, 0.017719092, 0.017767164, 0.017388066, 0.016922674, 0.016537550, 0.016521571, 0.016329574, 0.016087252, 0.015333185, 0.014314958, 0.012862059, 0.011321168, 0.009755944, 0.009256364, 0.008445667, 0.007593351, 0.006349995, 0.005493491, 0.004557222, 0.004642170, 0.005364849, 0.006375077, 0.006955036, 0.006871354, 0.006216022, 0.005252610, 0.004769276, 0.004932222, 0.005148679, 0.005305222, 0.004644044, 0.003616387, 0.002414268, 0.001617685, 0.002374725, 0.002971222, 0.002913218, 0.002719645, 0.002346166, 0.002575187, 0.002987921, 0.003136834, 0.003183764, 0.003413871, 0.003350896, 0.003073886, 0.002892891, 0.002265416, 0.001655378, 0.001560327, 0.001968299, 0.001995381, 0.001919509, 0.001992721, 0.002116618, 0.001886192, 0.001977474, 0.002126476, 0.002761516, 0.002651429, 0.002898811, 0.003334228, 0.003127383, 0.002904569, 0.003357476, 0.003112309, 0.003140989, 0.003023685, 0.002587393, 0.002277524, 0.002075252, 0.001928620, 0.002257961])
PointerLine = np.zeros((181))
Angle = 0
MaxValue = 60
v = v *1000
#v=20*np.log10(v/max(v)) #logarithmic scale -20dB .. 0 dB
PointerLine[Angle+90] = MaxValue
f1 = plt.figure(facecolor='white')
a1 = fractional_polar_axes(f1, (-90, 90.), (0, MaxValue), (10, 10),None, 'measured voltage (mV)', True)
MyTitle= 'Target angle %4.1f$^\circ$' %Angle
f1.suptitle( MyTitle, y=0.95)
a1.plot(theta, v, 'b')
a1.plot(theta, PointerLine,'r')
OutFileName='out_mv/angle_%02.2f' % Angle
#f1.savefig(OutFileName+'.eps')
f1.savefig('test.png', dpi=300)
plt.show()
最佳答案
我找到了旋转问题的解决方案:我添加了 tr_rotate 和 thta_offset
def fractional_polar_axes(f, thlim=(0, 180), rlim=(0, 1), step=(30, 0.2),
thlabel='theta', rlabel='r', ticklabels=True, theta_offset=0):
...
tr_rotate = Affine2D().translate(theta_offset, 0)
# scale degrees to radians:
tr_scale = Affine2D().scale(np.pi/180., 1.)
tr = tr_rotate + tr_scale + PolarAxes.PolarTransform()
对于我来说,零是 theta_offset=90 的位置。
r 为负值就可以了。使用“正常”极坐标图(ax = plt.subplot(111, Polar=True))它可以工作。
关于python - 具有 dB 刻度和负角度值的半极坐标图(方向性图),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26137222/
我有一个非常基本的 MySQL 查询,它从数据库表中读取行并将行值添加或减去定义为 $total_balance 的 PHP 字符串。 例如; $statement_details_query = m
我有 following fiddle ,请注意,如果您使输出的宽度变小,图像将被覆盖并且不会出现滚动条 - 完美。 如果我attempt the same effect on the right ,
这个正则表达式将得到 456。我的问题是为什么它不能是 1-234-56 中的 234 ? 56 是否限定 (?!\d)) 模式,因为它不是单个数字。 (?!\d)) 寻找的起始点在哪里? impor
我需要知道两个子结构之间的内存距离 (&my_type.a - &my_tape.b.c) 结果的类型是什么?我需要将它转换为 (signed int),所以显然它是别的东西。 最佳答案 根据 C11
我遇到了一个扩展异常的异常处理程序类,如下所示: public class AppFileReaderException extends Exception { //Explicit seri
如何可视化负 RGB 值? 根据 OpenCV 文档: CV_8S - 8 位有符号整数 (-128..127) 这是否意味着 -128 表示 0 而 127 表示 255? 如果是,那我们为什么需要
我这里有一段代码给我带来了麻烦: idIndex = panoBuffer.indexOf("\"photo_id\":"); System.out.println(idIndex);
我刚刚练习 Java,对此还很陌生。我只是想创建一个随机数生成器程序来跟踪玩家的获胜、失败、获胜百分比和总获胜金额。该程序的逻辑是,玩家每次 session 有 3 次机会,计算机会生成一个随机数,玩
因此,我们被要求创建一个程序,使用户能够从 1-6 个有关矩阵运算的选项中进行选择。在每个用户的输入中,我们需要检查该输入是否适合要完成的操作(程序应该接受整数或 float ,正数或负数)。如果不满
这是我期望的输出 x |x| 1.2 1.2 -2.3 2.3 3.4 3.4 但我一直收到这个: x |x| 1
假设我有这个: $date1=date_create(date('H:I', strtotime('8:00'))); $date2=date_create(date('H:I', strtotime
如何确定负 FixNum 的无符号解释? # unexpected, true (~0b01111011).to_s(2) == ("-" + (~0b01111011).abs.to_s(2)) #
这是一个用于“邀请您的 friend 加入此群组”脚本的快速 SQL 查询。 我有 2 个表:users 和 group_members。我正在尝试执行一个查询,选择我所有的 friend ——由第一
负 ASCII 值有什么意义? int a = '«'; //a = -85 but as in ASCII table '<<' should be 174 最佳答案 没有负数ASCII值。 ASC
我知道用 PHP 可以做到这一点,但是有没有办法只用 MySQL 来做到这一点? 我有这个数据库: --------------------------------------------------
我在变量中有一个时间戳 $data = (float) -2208988800; 是否可以根据这些数据创建正确的日期?date("d.M.Y", $data) 返回“07.02.2036” 最佳答案
你好我如何将括号格式的负值转换为 double 值。目前我有这个。 Payment.Text = Calc_Payment().ToString("#,##0.00;(#,##0.00)"); 将支付
这是一个小程序。这应该打印 0 或 1,还是它有未定义的行为? #include struct S0 { unsigned f1 : 1; }; struct S0 s; int main (v
运行 lgb.cv 时,我有时会从日志中看到“从分数开始训练”后的负数。想知道这个数字到底是什么意思,单位是什么?是根据参数中指定的指标吗?以下是摘录: [LightGBM] [Info] Total
我正在使用变分自动编码器类型模型,我的损失函数的一部分是均值为 0 和方差为 1 的正态分布与另一个均值和方差由我的模型预测的正态分布之间的 KL 散度。 我用以下方式定义了损失: def kl_lo
我是一名优秀的程序员,十分优秀!