Peeter Joot
Peeter Joot

Reputation: 8260

How to change radial ticks in julia PyPlot polar plot?

Using julia and PyPlot (which looks like it calls matplotlib) I've got a radial log plot ranging from 0dB on the outer edge of the plot to -50dB on the interior:

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]() ;

which looks like:

polar

I'd like to reset the polar ticks so that the radial tick markers are mapped from:

How can this be accomplished?

Upvotes: 3

Views: 1230

Answers (1)

tmdavison
tmdavison

Reputation: 69136

I've never used Julia, but you need to set the yticklabels. I think this should do it:

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

Upvotes: 6

Related Questions