python - 如何更改 julia PyPlot 极坐标图中的径向刻度?

标签 python matplotlib plot julia

使用 julia 和 PyPlot(看起来它称为 matplotlib)我得到了一个径向对数图,范围从图外边缘的 0dB 到内部的 -50dB:

using PyPlot ;

theta = 0:0.02:1 * pi ;
n = length(theta) ;

U = cos( theta ).^2 ;
V = zeros( size(U) ) ;

for i = 1:n
   v = log10( U[i] ) ;
   if ( v < -50/10 )
      v = 0 ;
   else
      v = v/5 + 1 ;
   end

   V[i] = v ;
end

f1 = figure("p2Fig1",figsize=(10,10)) ; # Create a new figure
ax1 = axes( polar="true" ) ; # Create a polar axis

pl1 = plot( theta, V, linestyle="-", marker="None" ) ;

dtheta = 30 ;
ax1[:set_thetagrids]([0:dtheta:360-dtheta]) ;
ax1[:set_theta_zero_location]("E") ;
f1[:canvas][:draw]() ;

看起来像:

polar

我想重置极地刻度,以便径向刻度标记映射自:

  • 1 -> 0 分贝
  • 0.8 -> -10 分贝
  • 0.6 -> -20 分贝
  • 0.4 -> -30 分贝
  • 0.2 -> -40 分贝

如何实现?

最佳答案

我从未使用过 Julia,但您需要设置 yticklabels。我认为应该这样做:

ax1[:set_yticks]([0.2,0.4,0.6,0.8,1.0])
ax1[:set_yticklabels](["-40dB","-30dB","-20dB","-10dB","0dB"])

关于python - 如何更改 julia PyPlot 极坐标图中的径向刻度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29921611/

相关文章:

python - 为什么 Bottle 不返回列表?

python - 以微秒分辨率绘制 pandas 数据帧

python - 删除 pandas plot.area 的抗锯齿

r - 使用密度图对特定区域进行着色 - ggplot2

python - VirtualBox Ubuntu 在尝试从 CMake 构建 CXX 对象时卡住

python - 如何用导航栏安排框架的布局

python - 如何关闭一个图形或替换一个图形而不必手动关闭 Python/pylab 中的每个图形?

python - 如何在 Seaborn PairGrid 中对齐 y 标签

python - imshow 当您绘制数据而不是图像时。 aspect 和 extent 之间的关系?

python - 任何维度的无限体积的交集