1
$\begingroup$

I am working with an external "number-crunching" application that generates radiation patterns for antennas. The data that I am working with is a function of spherical angles theta and phi and it produces numbers in the range of 0 through some maximum value. I want to plot using PolarPlot to show a "scaled" tick mark where the scaling is the result of some function that I write to do the proper transformation. So, here is an example [below, phi is controlled externally and sometimes via Manipulate[]).

PolarPlot[
  gdb[180/Pi (Abs[Pi/2 - theta]), phi], {theta, 0, Pi}, 
  PolarAxes -> True, PolarTicks -> {"Degrees", Automatic}, 
  PolarGridLines -> Automatic, PlotRangeClipping -> False, 
  PolarAxesOrigin -> Automatic]

And, this is the resultant plot:

PolarPlot

Now, the PolarAxesOrigin option given Automatic generates the axes labeled from 20 thru the maximum of 80. However, for this same plot, the only change I want (in this example) is to scale that axes tick mark labels as 0.0 for the 80 tick mark label and then the inner concentric circles would be -10, -20, -30, -40, and so on. Thus, the labeling are all negative numbers with zero as the maximum range on the PolarAxesOrigin.

I have researched various posted questions here and experimented using scaling features, tick functions, and other things (merely guessing) to figure out how to achieve this and nothing works right. I am hoping that I can provide some kind of function that can do a transformation from the plotted values to some scaled tick mark labels. Changing the data itself to be negative does not work, the resultant plot is not correct.

$\endgroup$
  • 3
    $\begingroup$ Your code is not a working example because there is no definition go gdb. So anyone who might want to help can't reproduce your problem, which greatly reduces the chance that you get an answer. $\endgroup$ – m_goldberg May 13 at 2:53
  • $\begingroup$ Sorry about that but the gdb function is an Interpolation of about 4000 or so data points for angles theta 0 to 90 and phi 0 to 360. So, not really a function that can be easily included. But, the range of the function I mentioned which of course varies over the domain variables. $\endgroup$ – K7PEH May 13 at 3:43
2
$\begingroup$

It's a shame you did not include your own function, so I will have to use a made up one. I do not know how to change that detail before the plot is generated, but inspection of the plot's InputForm (try plot // InputForm // SequenceForm) shows the general format of those labels. This can be modified after the fact as follows, using a global replacement to generate the ticks you want:

plot = PolarPlot[
         25 theta, {theta, 0, Pi},
         PolarAxes -> True,
         PolarTicks -> {"Degrees", Automatic},
         PolarGridLines -> Automatic,
         PlotRangeClipping -> False,
         PolarAxesOrigin -> Automatic
       ];

plot /. Text[Style[value_Real, {}], opts__] :> Text[Style[value - 80, {}], opts]

modified plot

Above I restricted the pattern for replacement using val_Real to avoid causing the same change to the angular ticks, which otherwise would also become e.g. 30° - 80. "30°" is represented internally as Times[30, Degree]; that expression has head Times to Mathematica's eyes, and is not a real number (i.e. something with head Real), so it can be distinguished from the radial ticks that are plain real numbers instead.

| improve this answer | |
$\endgroup$
  • $\begingroup$ A bit of a hack, this should be supported through a Ticks option no? $\endgroup$ – M.R. May 13 at 14:26
  • $\begingroup$ @M.R. It sure should be (indeed that was my first attempt), but I was unable to make Ticks work here, hence the hack, $\endgroup$ – MarcoB May 13 at 15:20
  • $\begingroup$ So, I did the same hack on my plot and it worked. Now, I need to figure out how it worked. I understand the rule substitution but I do not understand the reason it works. For example, Text[Style[value_Real,{}],opts__] is a pattern match but I would not have been able to come up with that pattern myself. I figure value_Real matches any real value but I have never seen that before "the value part". Also, why the opts__ ? Does this match any options to be used in the substitution (my guess). $\endgroup$ – K7PEH May 13 at 16:09
  • $\begingroup$ I noted that in my version of Mathematica (should be the most recent) the function SequenceForm is obsolete and no longer exists. It is to be replaced with Row or Text. I am not sure how this SequenceForm adds to the description of the InputForm so not sure how Row or Text would be used as a substitute. $\endgroup$ – K7PEH May 13 at 16:11
  • 1
    $\begingroup$ @K7PEH The output of InputForm is normally formatted as text and does not allow the usual context-aware selection (e.g. keep clicking with the mouse to expand selection in a syntax aware fashion). SequenceForm makes the output more easily editable. Row does not work as well for this; Text is an acceptable but inferior substitute. $\endgroup$ – MarcoB May 13 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.