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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108412] Re: How to extract the x-axis and y-axis current ticks of a plot
  • From: dh <dh at metrohm.com>
  • Date: Wed, 17 Mar 2010 04:37:52 -0500 (EST)
  • References: <hnnk37$che$1@smc.vnet.net>

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

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.
>
> thanks,
> --Nasser
>
>
>


-- 

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh at metrohm.com>
Internet:<http://www.metrohm.com>



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