MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to extract the x-axis and y-axis current ticks of a plot from AbsoluteOptions?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108414] Re: How to extract the x-axis and y-axis current ticks of a plot from AbsoluteOptions?
  • From: "Nasser M. Abbasi" <nma at 12000.org>
  • Date: Wed, 17 Mar 2010 04:38:14 -0500 (EST)
  • References: <hnnk37$che$1@smc.vnet.net> <4B9F90F5.6080303@metrohm.com>
  • Reply-to: "Nasser M. Abbasi" <nma at 12000.org>



>
> On 16.03.2010 10:47, Nasser M. Abbasi wrote:
>> Version 7:
>>
>> Many times I find I need to change the Plot Ticks (mostly to make the 
>> ticks
>> display in units of Pi for example instead of just in pure real numbers).
>>
>> The only way I know how to do this now is this:
>>
>> I build my own Ticks lists, and then do
>>
>> Plot[...,Ticks->{myXticks,myYTicks},....]
>>
>> But the problem with this, is tha I have to guess (Actually I do little 
>> more
>> than guessing) to obtain a good number of ticks to use, else I get too 
>> few
>> ticks or too many.
>>
>> But what would be better is to use the Ticks Mathematica uses on the plot
>> before I change the ticks myself. The reason is that I would know the 
>> most
>> optimal number of ticks to use.
>>
>> So, now What I want to do is this: First plot, but do not display, using
>> default Mathematica ticks. Then use AbsoluteOptions to get the ticks
>> information, then pull out the x-ticks list and the y-ticks from these,
>> modify each tick value to the value I want using my own transformation, 
>> then
>> set the plot again but now using the changed x and y ticks, then plot and
>> display.
>>
>> But I am stuck after getting the ticks information from the current plot. 
>> As
>> I am not able to figure how to pull out the x-ticks and y-ticks out of 
>> it. I
>> do not know how these are encoded in there.   Here is what I do
>>
>> p = Plot[Sin[x], {x, 0, 10}, Ticks ->  Automatic]
>> t = Ticks /. AbsoluteOptions[p]
>>
>> You can see from the plot, that x-ticks are {2,4,6,8,10}  and y-ticks are
>> {-1.0,0,.5,1}
>>
>> But I do not know how to pull these 2 lists out of the "t" variable 
>> above. I
>> just need the list of numbers (do not care about the other attributes 
>> such
>> as Thickness and GrayLevel and all that.)
>>
>>
>> Dimensions[t]
>> {2}
>>
>> Dimensions[t[[1]]]
>> {21, 4}
>>
>> Dimensions[t[[2]]]
>> {41, 4}
>>
>> Are these things documented somewhere? Looking at FullForm[t] was not 
>> much
>> help.
>>



> Hi Nasser,
> I think you make your life more cumbersum than necessary. Simply make a 
> Plot in units of Pi like e.g.:
> Plot[Sin[x Pi], {x, 0, 3}, AxesLabel -> {"x/Pi"},
>  PlotLabel -> "Sin[x]"]
> Daniel

I tried the above, but the ticks are not in units of Pi? I need the actual 
Ticks to display as  "Pi/2", "Pi/4", etc...

Thanks,
--Nasser











  • Prev by Date: Re: Algebraic reduction
  • Next by Date: Re: How to extract the x-axis and y-axis current ticks of a plot from
  • Previous by thread: How to extract the x-axis and y-axis current ticks of a plot from AbsoluteOptions?
  • Next by thread: Axeslabel containing capital n