Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7233 > unrolled thread

precision of y-axis values in plot

Started byNathan <nhrollins@gmail.com>
First post2011-12-15 10:01 +0000
Last post2011-12-20 08:05 +0000
Articles 9 — 5 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  precision of y-axis values in plot Nathan <nhrollins@gmail.com> - 2011-12-15 10:01 +0000
    Re: precision of y-axis values in plot Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-12-16 11:04 +0000
      Re: precision of y-axis values in plot Nathan <nhrollins@gmail.com> - 2011-12-17 07:44 +0000
        Re: precision of y-axis values in plot Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-12-18 09:38 +0000
      Re: precision of y-axis values in plot DrMajorBob <btreat1@austin.rr.com> - 2011-12-19 12:26 +0000
      Re: precision of y-axis values in plot DrMajorBob <btreat1@austin.rr.com> - 2011-12-20 08:04 +0000
      Re: precision of y-axis values in plot Heike Gramberg <heike.gramberg@gmail.com> - 2011-12-20 08:06 +0000
    Re: precision of y-axis values in plot Mike H <mike.honeychurch@gmail.com> - 2011-12-19 12:18 +0000
    Re: precision of y-axis values in plot DrMajorBob <btreat1@austin.rr.com> - 2011-12-20 08:05 +0000

#7233 — precision of y-axis values in plot

FromNathan <nhrollins@gmail.com>
Date2011-12-15 10:01 +0000
Subjectprecision of y-axis values in plot
Message-ID<jccgik$min$1@smc.vnet.net>
Hi,

I'm relatively new to Mathematica.  I'm having a problem with the
precision of the y-axis values of some of my plots.  All of the data
labels show up as "2422.3", which isn't very informative since they're
all the same.  I need the plot to show two more decimal point values
(ex: "2422.305").  I've looked high and low and can't find any way to
do this.  Any ideals?  Thanks!

Nathan.

[toc] | [next] | [standalone]


#7276

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2011-12-16 11:04 +0000
Message-ID<jcf8kl$70m$1@smc.vnet.net>
In reply to#7233
On Dec 15, 9:01 pm, Nathan <nhroll...@gmail.com> wrote:
> Hi,
>
> I'm relatively new to Mathematica.  I'm having a problem with the
> precision of the y-axis values of some of my plots.  All of the data
> labels show up as "2422.3", which isn't very informative since they're
> all the same.  I need the plot to show two more decimal point values
> (ex: "2422.305").  I've looked high and low and can't find any way to
> do this.  Any ideals?  Thanks!
>
> Nathan.

What you need to do is make a tick function and wrap NumberForm around
your labels and set the number of decimal points that you want. If you
do a search on here for tick functions and NumberForm you should find
many examples.

Mike

[toc] | [prev] | [next] | [standalone]


#7291

FromNathan <nhrollins@gmail.com>
Date2011-12-17 07:44 +0000
Message-ID<jchh8v$ida$1@smc.vnet.net>
In reply to#7276
On Dec 16, 4:04 am, Armand Tamzarian <mike.honeychu...@gmail.com>
wrote:
> On Dec 15, 9:01 pm, Nathan <nhroll...@gmail.com> wrote:
>
> > Hi,
>
> > I'm relatively new to Mathematica.  I'm having a problem with the
> > precision of the y-axis values of some of my plots.  All of the data
> > labels show up as "2422.3", which isn't very informative since they're
> > all the same.  I need the plot to show two more decimal point values
> > (ex: "2422.305").  I've looked high and low and can't find any way to
> > do this.  Any ideals?  Thanks!
>
> > Nathan.
>
> What you need to do is make a tick function and wrap NumberForm around
> your labels and set the number of decimal points that you want. If you
> do a search on here for tick functions and NumberForm you should find
> many examples.
>
> Mike

Mike,

Thank you for your help.  Forgive my ignorance, but what should I put
in the NumberForm function?  Here's the plot command I'm using:

plot2T :=  Plot[LT2[T, \[Lambda]], {T, min2, max2}, Frame -> True,
FrameLabel -> {{"Task Execution Time (s)",      ""}, {"Optimal CSCP
Checkpoint Interval (s)", ""}},   FrameStyle -> {{Black, White},
{Black, White}},   Axes -> {False, False}]

Based on what you said, I assume I should add something like the
following to the Plot function:
Tick -> NumberForm[ N[?], 8]

However, I'm not sure what should replace the ?.  Will you please
indulge a newbie with a specific example?  Thanks!

[toc] | [prev] | [next] | [standalone]


#7328

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2011-12-18 09:38 +0000
Message-ID<jckcam$1lt$1@smc.vnet.net>
In reply to#7291
On Dec 17, 6:44 pm, Nathan <nhroll...@gmail.com> wrote:
> On Dec 16, 4:04 am, Armand Tamzarian <mike.honeychu...@gmail.com>
> wrote:
>
>
>
>
>
>
>
>
>
> > On Dec 15, 9:01 pm, Nathan <nhroll...@gmail.com> wrote:
>
> > > Hi,
>
> > > I'm relatively new to Mathematica.  I'm having a problem with the
> > > precision of the y-axis values of some of my plots.  All of the data
> > > labels show up as "2422.3", which isn't very informative since they're
> > > all the same.  I need the plot to show two more decimal point values
> > > (ex: "2422.305").  I've looked high and low and can't find any way to
> > > do this.  Any ideals?  Thanks!
>
> > > Nathan.
>
> > What you need to do is make a tick function and wrap NumberForm around
> > your labels and set the number of decimal points that you want. If you
> > do a search on here for tick functions and NumberForm you should find
> > many examples.
>
> > Mike
>
> Mike,
>
> Thank you for your help.  Forgive my ignorance, but what should I put
> in the NumberForm function?  Here's the plot command I'm using:
>
> plot2T :=  Plot[LT2[T, \[Lambda]], {T, min2, max2}, Frame -> True,
> FrameLabel -> {{"Task Execution Time (s)",      ""}, {"Optimal CSCP
> Checkpoint Interval (s)", ""}},   FrameStyle -> {{Black, White},
> {Black, White}},   Axes -> {False, False}]
>
> Based on what you said, I assume I should add something like the
> following to the Plot function:
> Tick -> NumberForm[ N[?], 8]
>
> However, I'm not sure what should replace the ?.  Will you please
> indulge a newbie with a specific example?  Thanks!


tickFunction[min_, max_] := Table[{i, NumberForm[i, {3, 4}]}, {i, min,
max, 1/7}]

Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction]

You will need to read the documentation on Ticks and NumberForm to get
this to do exactly what you want.

Mike

[toc] | [prev] | [next] | [standalone]


#7355

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-12-19 12:26 +0000
Message-ID<jcnahq$e9k$1@smc.vnet.net>
In reply to#7276
The behavior of Ticks -> func is not explained in Help for Ticks -- and no  
examples are given -- so I suppose any guess is as good as another. It's  
pretty clear that Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}]  
should yield tick marks separated by about

1/7.

0.142857

The question is what "min" and "max" arguments are used.

When I run this code:

tickFunction[min_, max_] := Table[{i, NumberForm[i, {3, 4}]}, {i, min,
max, 1/7}]

Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction]

The ticks I see are {0.1220, 0.2650, 0.4081, 0.5510, .6930, .8360,  
0.9790}, which are spaced just about right:

differences =
  Subtract @@@
   Partition[
    ticks = {0.1220, 0.2650, 0.4081, 0.5510, .6930, .8360, 0.9790}, 2,
    1]
-7 Rationalize@Mean@%

{-0.143, -0.1431, -0.1429, -0.142, -0.143, -0.143}

5999/6000

xmin = 0.1220 should be the first tick mark, and xmax could be 1.12186:

Through[{First, Last}@ticks] + {0, 1}/7
(tickFunction @@ %)[[All, 1]]

{0.122, 1.12186}

{0.122, 0.264857, 0.407714, 0.550571, 0.693429, 0.836286, 0.979143}

but those are not the plotted tick marks. (Close, but no cigar.)

If we modify tickFunction to get the arguments directly, a very different  
result arises:

tickFunction[min_, max_] := (limits = {min, max};
   Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}])
Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction];
limits
(tickFunction @@ limits)[[All, 1]]

{-0.0175306, 0.859002}

{-0.0175306, 0.125326, 0.268184, 0.411041, 0.553898, 0.696755, \
0.839612}

Those are really, REALLY not the tick marks on the plot.

Don't you just love the documentation?

Bobby

On Sun, 18 Dec 2011 03:36:44 -0600, Armand Tamzarian  
<mike.honeychurch@gmail.com> wrote:

> On Dec 17, 6:44 pm, Nathan <nhroll...@gmail.com> wrote:
>> On Dec 16, 4:04 am, Armand Tamzarian <mike.honeychu...@gmail.com>
>> wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> > On Dec 15, 9:01 pm, Nathan <nhroll...@gmail.com> wrote:
>>
>> > > Hi,
>>
>> > > I'm relatively new to Mathematica.  I'm having a problem with the
>> > > precision of the y-axis values of some of my plots.  All of the data
>> > > labels show up as "2422.3", which isn't very informative since  
>> they're
>> > > all the same.  I need the plot to show two more decimal point values
>> > > (ex: "2422.305").  I've looked high and low and can't find any way  
>> to
>> > > do this.  Any ideals?  Thanks!
>>
>> > > Nathan.
>>
>> > What you need to do is make a tick function and wrap NumberForm around
>> > your labels and set the number of decimal points that you want. If you
>> > do a search on here for tick functions and NumberForm you should find
>> > many examples.
>>
>> > Mike
>>
>> Mike,
>>
>> Thank you for your help.  Forgive my ignorance, but what should I put
>> in the NumberForm function?  Here's the plot command I'm using:
>>
>> plot2T :=  Plot[LT2[T, \[Lambda]], {T, min2, max2}, Frame -> True,
>> FrameLabel -> {{"Task Execution Time (s)",      ""}, {"Optimal CSCP
>> Checkpoint Interval (s)", ""}},   FrameStyle -> {{Black, White},
>> {Black, White}},   Axes -> {False, False}]
>>
>> Based on what you said, I assume I should add something like the
>> following to the Plot function:
>> Tick -> NumberForm[ N[?], 8]
>>
>> However, I'm not sure what should replace the ?.  Will you please
>> indulge a newbie with a specific example?  Thanks!
>
>
> tickFunction[min_, max_] := Table[{i, NumberForm[i, {3, 4}]}, {i, min,
> max, 1/7}]
>
> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction]
>
> You will need to read the documentation on Ticks and NumberForm to get
> this to do exactly what you want.
>
> Mike
>


-- 
DrMajorBob@yahoo.com

[toc] | [prev] | [next] | [standalone]


#7357

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-12-20 08:04 +0000
Message-ID<jcpfig$qek$1@smc.vnet.net>
In reply to#7276
Your printed limits -- {-0.0208333,1.02083} -- don't match those I  
retrieved from a similar function -- {-0.0175306, 0.859002} -- but  
otherwise...

Thanks.

Maybe automatic padding was different here because of my screen  
resolution, notebook magnification, time zone, moon phase, or what I was  
wearing.

Bobby

On Sun, 18 Dec 2011 15:16:14 -0600, Mike H <mike.honeychurch@gmail.com>  
wrote:

> Okay here is what is happening.
>
> Firstly your limits variable is capturing the y axis range.
>
> If we change the tick function to this:
>
> tickFunction[min_, max_] := (Print[{min, max}];
>   Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}])
>
> Plot[Sin[x], {x, 0, 1}, Ticks -> {tickFunction, tickFunction}]
>
> We get both ranges printed.
>
> {-0.0208333,1.02083}
> {-0.0175306,0.859002}
>
> Now you might ask why, when you are plotting from 0 to 1 why we are  
> getting
> {-0.0208333,1.02083} parsed to the tick function. The answer is because  
> it
> turns that the plot range used in the tick function includes the plot  
> range
> padding. When you set
>
> Plot[Sin[x], {x, 0, 1}, Ticks -> {tickFunction, tickFunction},
> PlotRangePadding -> 0]
>
> {0.,1.}
> {0.,0.841471}
>
> and the ticks are exactly where you expect them. I didn't notice this  
> when
> I wrote the answer yesterday. As for the documentation, I haven't looked  
> at
> tick funcitons in years but I am sure I remember it being there in the  
> old
> (V4, V5)documentation.
>
> Mike
>
>
> On Mon, Dec 19, 2011 at 5:59 AM, DrMajorBob <btreat1@austin.rr.com>  
> wrote:
>
>> The behavior of Ticks -> func is not explained in Help for Ticks -- and  
>> no
>> examples are given -- so I suppose any guess is as good as another. It's
>> pretty clear that Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}]
>> should yield tick marks separated by about
>>
>> 1/7.
>>
>> 0.142857
>>
>> The question is what "min" and "max" arguments are used.
>>
>> When I run this code:
>>
>> tickFunction[min_, max_] := Table[{i, NumberForm[i, {3, 4}]}, {i, min,
>> max, 1/7}]
>>
>> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction]
>>
>> The ticks I see are {0.1220, 0.2650, 0.4081, 0.5510, .6930, .8360,
>> 0.9790}, which are spaced just about right:
>>
>> differences =
>>  Subtract @@@
>>  Partition[
>>   ticks = {0.1220, 0.2650, 0.4081, 0.5510, .6930, .8360, 0.9790}, 2,
>>   1]
>> -7 Rationalize@Mean@%
>>
>> {-0.143, -0.1431, -0.1429, -0.142, -0.143, -0.143}
>>
>> 5999/6000
>>
>> xmin = 0.1220 should be the first tick mark, and xmax could be 1.12186:
>>
>> Through[{First, Last}@ticks] + {0, 1}/7
>> (tickFunction @@ %)[[All, 1]]
>>
>> {0.122, 1.12186}
>>
>> {0.122, 0.264857, 0.407714, 0.550571, 0.693429, 0.836286, 0.979143}
>>
>> but those are not the plotted tick marks. (Close, but no cigar.)
>>
>> If we modify tickFunction to get the arguments directly, a very  
>> different
>> result arises:
>>
>> tickFunction[min_, max_] := (limits = {min, max};
>>  Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}])
>> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction];
>> limits
>> (tickFunction @@ limits)[[All, 1]]
>>
>> {-0.0175306, 0.859002}
>>
>> {-0.0175306, 0.125326, 0.268184, 0.411041, 0.553898, 0.696755, \
>> 0.839612}
>>
>> Those are really, REALLY not the tick marks on the plot.
>>
>> Don't you just love the documentation?
>>
>> Bobby
>>
>> On Sun, 18 Dec 2011 03:36:44 -0600, Armand Tamzarian <
>> mike.honeychurch@gmail.com> wrote:
>>
>>  On Dec 17, 6:44 pm, Nathan <nhroll...@gmail.com> wrote:
>>>
>>>> On Dec 16, 4:04 am, Armand Tamzarian <mike.honeychu...@gmail.com>
>>>> wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> > On Dec 15, 9:01 pm, Nathan <nhroll...@gmail.com> wrote:
>>>>
>>>> > > Hi,
>>>>
>>>> > > I'm relatively new to Mathematica.  I'm having a problem with the
>>>> > > precision of the y-axis values of some of my plots.  All of the  
>>>> data
>>>> > > labels show up as "2422.3", which isn't very informative since
>>>> they're
>>>> > > all the same.  I need the plot to show two more decimal point  
>>>> values
>>>> > > (ex: "2422.305").  I've looked high and low and can't find any  
>>>> way to
>>>> > > do this.  Any ideals?  Thanks!
>>>>
>>>> > > Nathan.
>>>>
>>>> > What you need to do is make a tick function and wrap NumberForm  
>>>> around
>>>> > your labels and set the number of decimal points that you want. If  
>>>> you
>>>> > do a search on here for tick functions and NumberForm you should  
>>>> find
>>>> > many examples.
>>>>
>>>> > Mike
>>>>
>>>> Mike,
>>>>
>>>> Thank you for your help.  Forgive my ignorance, but what should I put
>>>> in the NumberForm function?  Here's the plot command I'm using:
>>>>
>>>> plot2T :=  Plot[LT2[T, \[Lambda]], {T, min2, max2}, Frame -> True,
>>>> FrameLabel -> {{"Task Execution Time (s)",      ""}, {"Optimal CSCP
>>>> Checkpoint Interval (s)", ""}},   FrameStyle -> {{Black, White},
>>>> {Black, White}},   Axes -> {False, False}]
>>>>
>>>> Based on what you said, I assume I should add something like the
>>>> following to the Plot function:
>>>> Tick -> NumberForm[ N[?], 8]
>>>>
>>>> However, I'm not sure what should replace the ?.  Will you please
>>>> indulge a newbie with a specific example?  Thanks!
>>>>
>>>
>>>
>>> tickFunction[min_, max_] := Table[{i, NumberForm[i, {3, 4}]}, {i, min,
>>> max, 1/7}]
>>>
>>> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction]
>>>
>>> You will need to read the documentation on Ticks and NumberForm to get
>>> this to do exactly what you want.
>>>
>>> Mike
>>>
>>>
>>
>> --
>> DrMajorBob@yahoo.com
>>


-- 
DrMajorBob@yahoo.com

[toc] | [prev] | [next] | [standalone]


#7365

FromHeike Gramberg <heike.gramberg@gmail.com>
Date2011-12-20 08:06 +0000
Message-ID<jcpfmb$qgr$1@smc.vnet.net>
In reply to#7276
The values for min and max values used in Ticks->func are the min and max values of the total
plot range of the plot which is a combination of PlotRange and PlotRangePadding. Consider for
example

tickFunction[min_, max_] := (Table[i, {i, min, max, (max - min)/7}])
Plot[Sin[x], {x, 0, 1}, PlotRange -> Automatic,
 PlotRangePadding -> 0.1, Ticks -> tickFunction]

Then the ticks along the x-axis run from -.1 to 1.1 which is the plot range in the x-direction plus
a padding of .1 on both sides. If an explicit PlotRange is given then PlotRangePadding is
ignored and min and max values are taken directly from PlotRange. Consider for example

Plot[Sin[x], {x, 0, 1}, PlotRange -> {{-.2, 1.3}, {-.2, 1}}, Ticks -> tickFunction]

Calculating the total plot range in the original case is slightly more complicated since the
default value for PlotRangePadding is Scaled[0.02], which means that 2 percent of the total
plot range in the final plot is padding, and the rest is the plot range which you would find with

AbsoluteOptions[Plot[Sin[x], {x, 0, 1}], PlotRange]

which is equal to {PlotRange -> {{0., 1.}, {0., 0.841471}}} in this case. This means that the 
total plot range in the horizontal direction is 1./(1-2*.02)==1.04167.  The amount of padding on
the left and right-hand side is then .02*1.04167==0.0208334. Therefore, with
tickFunction[min_, max_] := (Table[i, {i, min, max, (max - min)/7}]) we would expect tick marks
along the horizontal axis at

tickFunction[-.0208334, 1.0208334]== {-0.0208334, 0.127976, 0.276786, 0.425595,
0.574405, 0.723214, 0.872024, 1.02083}

which is exactly what we get with Plot[Sin[x], {x, 0, 1}, Ticks->tickFunction]

By the way the tick marks you found on the last line are the tick marks along the y-axis.
Apparently they were calculated after the tick marks along the x-axis were calculated
which overwrote limits in your tickFunction.

Heike.


On 19 Dec 2011, at 13:22, DrMajorBob wrote:

> The behavior of Ticks -> func is not explained in Help for Ticks -- and no 
> examples are given -- so I suppose any guess is as good as another. It's 
> pretty clear that Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}] 
> should yield tick marks separated by about
>
> 1/7.
>
> 0.142857
>
> The question is what "min" and "max" arguments are used.
>
> When I run this code:
>
> tickFunction[min_, max_] := Table[{i, NumberForm[i, {3, 4}]}, {i, min,
> max, 1/7}]
>
> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction]
>
> The ticks I see are {0.1220, 0.2650, 0.4081, 0.5510, .6930, .8360, 
> 0.9790}, which are spaced just about right:
>
> differences =
>  Subtract @@@
>   Partition[
>    ticks = {0.1220, 0.2650, 0.4081, 0.5510, .6930, .8360, 0.9790}, 2,
>    1]
> -7 Rationalize@Mean@%
>
> {-0.143, -0.1431, -0.1429, -0.142, -0.143, -0.143}
>
> 5999/6000
>
> xmin = 0.1220 should be the first tick mark, and xmax could be 1.12186:
>
> Through[{First, Last}@ticks] + {0, 1}/7
> (tickFunction @@ %)[[All, 1]]
>
> {0.122, 1.12186}
>
> {0.122, 0.264857, 0.407714, 0.550571, 0.693429, 0.836286, 0.979143}
>
> but those are not the plotted tick marks. (Close, but no cigar.)
>
> If we modify tickFunction to get the arguments directly, a very different 
> result arises:
>
> tickFunction[min_, max_] := (limits = {min, max};
>   Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}])
> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction];
> limits
> (tickFunction @@ limits)[[All, 1]]
>
> {-0.0175306, 0.859002}
>
> {-0.0175306, 0.125326, 0.268184, 0.411041, 0.553898, 0.696755, \
> 0.839612}
>
> Those are really, REALLY not the tick marks on the plot.
>
> Don't you just love the documentation?
>
> Bobby
>
> On Sun, 18 Dec 2011 03:36:44 -0600, Armand Tamzarian 
> <mike.honeychurch@gmail.com> wrote:
>
>> On Dec 17, 6:44 pm, Nathan <nhroll...@gmail.com> wrote:
>>> On Dec 16, 4:04 am, Armand Tamzarian <mike.honeychu...@gmail.com>
>>> wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>> On Dec 15, 9:01 pm, Nathan <nhroll...@gmail.com> wrote:
>>>
>>>>> Hi,
>>>
>>>>> I'm relatively new to Mathematica.  I'm having a problem with the
>>>>> precision of the y-axis values of some of my plots.  All of the data
>>>>> labels show up as "2422.3", which isn't very informative since 
>>> they're
>>>>> all the same.  I need the plot to show two more decimal point values
>>>>> (ex: "2422.305").  I've looked high and low and can't find any way 
>>> to
>>>>> do this.  Any ideals?  Thanks!
>>>
>>>>> Nathan.
>>>
>>>> What you need to do is make a tick function and wrap NumberForm around
>>>> your labels and set the number of decimal points that you want. If you
>>>> do a search on here for tick functions and NumberForm you should find
>>>> many examples.
>>>
>>>> Mike
>>>
>>> Mike,
>>>
>>> Thank you for your help.  Forgive my ignorance, but what should I put
>>> in the NumberForm function?  Here's the plot command I'm using:
>>>
>>> plot2T :=  Plot[LT2[T, \[Lambda]], {T, min2, max2}, Frame -> True,
>>> FrameLabel -> {{"Task Execution Time (s)",      ""}, {"Optimal CSCP
>>> Checkpoint Interval (s)", ""}},   FrameStyle -> {{Black, White},
>>> {Black, White}},   Axes -> {False, False}]
>>>
>>> Based on what you said, I assume I should add something like the
>>> following to the Plot function:
>>> Tick -> NumberForm[ N[?], 8]
>>>
>>> However, I'm not sure what should replace the ?.  Will you please
>>> indulge a newbie with a specific example?  Thanks!
>>
>>
>> tickFunction[min_, max_] := Table[{i, NumberForm[i, {3, 4}]}, {i, min,
>> max, 1/7}]
>>
>> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction]
>>
>> You will need to read the documentation on Ticks and NumberForm to get
>> this to do exactly what you want.
>>
>> Mike
>>
>
>
> --
> DrMajorBob@yahoo.com
>

[toc] | [prev] | [next] | [standalone]


#7340

FromMike H <mike.honeychurch@gmail.com>
Date2011-12-19 12:18 +0000
Message-ID<jcna3e$e4s$1@smc.vnet.net>
In reply to#7233
Okay here is what is happening.

Firstly your limits variable is capturing the y axis range.

If we change the tick function to this:

tickFunction[min_, max_] := (Print[{min, max}];
  Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}])

Plot[Sin[x], {x, 0, 1}, Ticks -> {tickFunction, tickFunction}]

We get both ranges printed.

{-0.0208333,1.02083}
{-0.0175306,0.859002}

Now you might ask why, when you are plotting from 0 to 1 why we are getting
{-0.0208333,1.02083} parsed to the tick function. The answer is because it
turns that the plot range used in the tick function includes the plot range
padding. When you set

Plot[Sin[x], {x, 0, 1}, Ticks -> {tickFunction, tickFunction},
PlotRangePadding -> 0]

{0.,1.}
{0.,0.841471}

and the ticks are exactly where you expect them. I didn't notice this when
I wrote the answer yesterday. As for the documentation, I haven't looked at
tick funcitons in years but I am sure I remember it being there in the old
(V4, V5)documentation.

Mike


On Mon, Dec 19, 2011 at 5:59 AM, DrMajorBob <btreat1@austin.rr.com> wrote:

> The behavior of Ticks -> func is not explained in Help for Ticks -- and no
> examples are given -- so I suppose any guess is as good as another. It's
> pretty clear that Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}]
> should yield tick marks separated by about
>
> 1/7.
>
> 0.142857
>
> The question is what "min" and "max" arguments are used.
>
> When I run this code:
>
> tickFunction[min_, max_] := Table[{i, NumberForm[i, {3, 4}]}, {i, min,
> max, 1/7}]
>
> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction]
>
> The ticks I see are {0.1220, 0.2650, 0.4081, 0.5510, .6930, .8360,
> 0.9790}, which are spaced just about right:
>
> differences =
>  Subtract @@@
>  Partition[
>   ticks = {0.1220, 0.2650, 0.4081, 0.5510, .6930, .8360, 0.9790}, 2,
>   1]
> -7 Rationalize@Mean@%
>
> {-0.143, -0.1431, -0.1429, -0.142, -0.143, -0.143}
>
> 5999/6000
>
> xmin = 0.1220 should be the first tick mark, and xmax could be 1.12186:
>
> Through[{First, Last}@ticks] + {0, 1}/7
> (tickFunction @@ %)[[All, 1]]
>
> {0.122, 1.12186}
>
> {0.122, 0.264857, 0.407714, 0.550571, 0.693429, 0.836286, 0.979143}
>
> but those are not the plotted tick marks. (Close, but no cigar.)
>
> If we modify tickFunction to get the arguments directly, a very different
> result arises:
>
> tickFunction[min_, max_] := (limits = {min, max};
>  Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}])
> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction];
> limits
> (tickFunction @@ limits)[[All, 1]]
>
> {-0.0175306, 0.859002}
>
> {-0.0175306, 0.125326, 0.268184, 0.411041, 0.553898, 0.696755, \
> 0.839612}
>
> Those are really, REALLY not the tick marks on the plot.
>
> Don't you just love the documentation?
>
> Bobby
>
> On Sun, 18 Dec 2011 03:36:44 -0600, Armand Tamzarian <
> mike.honeychurch@gmail.com> wrote:
>
>  On Dec 17, 6:44 pm, Nathan <nhroll...@gmail.com> wrote:
>>
>>> On Dec 16, 4:04 am, Armand Tamzarian <mike.honeychu...@gmail.com>
>>> wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> > On Dec 15, 9:01 pm, Nathan <nhroll...@gmail.com> wrote:
>>>
>>> > > Hi,
>>>
>>> > > I'm relatively new to Mathematica.  I'm having a problem with the
>>> > > precision of the y-axis values of some of my plots.  All of the data
>>> > > labels show up as "2422.3", which isn't very informative since
>>> they're
>>> > > all the same.  I need the plot to show two more decimal point values
>>> > > (ex: "2422.305").  I've looked high and low and can't find any way to
>>> > > do this.  Any ideals?  Thanks!
>>>
>>> > > Nathan.
>>>
>>> > What you need to do is make a tick function and wrap NumberForm around
>>> > your labels and set the number of decimal points that you want. If you
>>> > do a search on here for tick functions and NumberForm you should find
>>> > many examples.
>>>
>>> > Mike
>>>
>>> Mike,
>>>
>>> Thank you for your help.  Forgive my ignorance, but what should I put
>>> in the NumberForm function?  Here's the plot command I'm using:
>>>
>>> plot2T :=  Plot[LT2[T, \[Lambda]], {T, min2, max2}, Frame -> True,
>>> FrameLabel -> {{"Task Execution Time (s)",      ""}, {"Optimal CSCP
>>> Checkpoint Interval (s)", ""}},   FrameStyle -> {{Black, White},
>>> {Black, White}},   Axes -> {False, False}]
>>>
>>> Based on what you said, I assume I should add something like the
>>> following to the Plot function:
>>> Tick -> NumberForm[ N[?], 8]
>>>
>>> However, I'm not sure what should replace the ?.  Will you please
>>> indulge a newbie with a specific example?  Thanks!
>>>
>>
>>
>> tickFunction[min_, max_] := Table[{i, NumberForm[i, {3, 4}]}, {i, min,
>> max, 1/7}]
>>
>> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction]
>>
>> You will need to read the documentation on Ticks and NumberForm to get
>> this to do exactly what you want.
>>
>> Mike
>>
>>
>
> --
> DrMajorBob@yahoo.com
>

[toc] | [prev] | [next] | [standalone]


#7363

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-12-20 08:05 +0000
Message-ID<jcpfkd$qfq$1@smc.vnet.net>
In reply to#7233
Oops, I missed the part about "limits" capturing the y range.

Bobby

On Mon, 19 Dec 2011 06:17:18 -0600, Mike H <mike.honeychurch@gmail.com>  
wrote:

> Okay here is what is happening.
>
> Firstly your limits variable is capturing the y axis range.
>
> If we change the tick function to this:
>
> tickFunction[min_, max_] := (Print[{min, max}];
>   Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}])
>
> Plot[Sin[x], {x, 0, 1}, Ticks -> {tickFunction, tickFunction}]
>
> We get both ranges printed.
>
> {-0.0208333,1.02083}
> {-0.0175306,0.859002}
>
> Now you might ask why, when you are plotting from 0 to 1 why we are  
> getting
> {-0.0208333,1.02083} parsed to the tick function. The answer is because  
> it
> turns that the plot range used in the tick function includes the plot  
> range
> padding. When you set
>
> Plot[Sin[x], {x, 0, 1}, Ticks -> {tickFunction, tickFunction},
> PlotRangePadding -> 0]
>
> {0.,1.}
> {0.,0.841471}
>
> and the ticks are exactly where you expect them. I didn't notice this  
> when
> I wrote the answer yesterday. As for the documentation, I haven't looked  
> at
> tick funcitons in years but I am sure I remember it being there in the  
> old
> (V4, V5)documentation.
>
> Mike
>
>
> On Mon, Dec 19, 2011 at 5:59 AM, DrMajorBob <btreat1@austin.rr.com>  
> wrote:
>
>> The behavior of Ticks -> func is not explained in Help for Ticks -- and  
>> no
>> examples are given -- so I suppose any guess is as good as another. It's
>> pretty clear that Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}]
>> should yield tick marks separated by about
>>
>> 1/7.
>>
>> 0.142857
>>
>> The question is what "min" and "max" arguments are used.
>>
>> When I run this code:
>>
>> tickFunction[min_, max_] := Table[{i, NumberForm[i, {3, 4}]}, {i, min,
>> max, 1/7}]
>>
>> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction]
>>
>> The ticks I see are {0.1220, 0.2650, 0.4081, 0.5510, .6930, .8360,
>> 0.9790}, which are spaced just about right:
>>
>> differences =
>>  Subtract @@@
>>  Partition[
>>   ticks = {0.1220, 0.2650, 0.4081, 0.5510, .6930, .8360, 0.9790}, 2,
>>   1]
>> -7 Rationalize@Mean@%
>>
>> {-0.143, -0.1431, -0.1429, -0.142, -0.143, -0.143}
>>
>> 5999/6000
>>
>> xmin = 0.1220 should be the first tick mark, and xmax could be 1.12186:
>>
>> Through[{First, Last}@ticks] + {0, 1}/7
>> (tickFunction @@ %)[[All, 1]]
>>
>> {0.122, 1.12186}
>>
>> {0.122, 0.264857, 0.407714, 0.550571, 0.693429, 0.836286, 0.979143}
>>
>> but those are not the plotted tick marks. (Close, but no cigar.)
>>
>> If we modify tickFunction to get the arguments directly, a very  
>> different
>> result arises:
>>
>> tickFunction[min_, max_] := (limits = {min, max};
>>  Table[{i, NumberForm[i, {3, 4}]}, {i, min, max, 1/7}])
>> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction];
>> limits
>> (tickFunction @@ limits)[[All, 1]]
>>
>> {-0.0175306, 0.859002}
>>
>> {-0.0175306, 0.125326, 0.268184, 0.411041, 0.553898, 0.696755, \
>> 0.839612}
>>
>> Those are really, REALLY not the tick marks on the plot.
>>
>> Don't you just love the documentation?
>>
>> Bobby
>>
>> On Sun, 18 Dec 2011 03:36:44 -0600, Armand Tamzarian <
>> mike.honeychurch@gmail.com> wrote:
>>
>>  On Dec 17, 6:44 pm, Nathan <nhroll...@gmail.com> wrote:
>>>
>>>> On Dec 16, 4:04 am, Armand Tamzarian <mike.honeychu...@gmail.com>
>>>> wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> > On Dec 15, 9:01 pm, Nathan <nhroll...@gmail.com> wrote:
>>>>
>>>> > > Hi,
>>>>
>>>> > > I'm relatively new to Mathematica.  I'm having a problem with the
>>>> > > precision of the y-axis values of some of my plots.  All of the  
>>>> data
>>>> > > labels show up as "2422.3", which isn't very informative since
>>>> they're
>>>> > > all the same.  I need the plot to show two more decimal point  
>>>> values
>>>> > > (ex: "2422.305").  I've looked high and low and can't find any  
>>>> way to
>>>> > > do this.  Any ideals?  Thanks!
>>>>
>>>> > > Nathan.
>>>>
>>>> > What you need to do is make a tick function and wrap NumberForm  
>>>> around
>>>> > your labels and set the number of decimal points that you want. If  
>>>> you
>>>> > do a search on here for tick functions and NumberForm you should  
>>>> find
>>>> > many examples.
>>>>
>>>> > Mike
>>>>
>>>> Mike,
>>>>
>>>> Thank you for your help.  Forgive my ignorance, but what should I put
>>>> in the NumberForm function?  Here's the plot command I'm using:
>>>>
>>>> plot2T :=  Plot[LT2[T, \[Lambda]], {T, min2, max2}, Frame -> True,
>>>> FrameLabel -> {{"Task Execution Time (s)",      ""}, {"Optimal CSCP
>>>> Checkpoint Interval (s)", ""}},   FrameStyle -> {{Black, White},
>>>> {Black, White}},   Axes -> {False, False}]
>>>>
>>>> Based on what you said, I assume I should add something like the
>>>> following to the Plot function:
>>>> Tick -> NumberForm[ N[?], 8]
>>>>
>>>> However, I'm not sure what should replace the ?.  Will you please
>>>> indulge a newbie with a specific example?  Thanks!
>>>>
>>>
>>>
>>> tickFunction[min_, max_] := Table[{i, NumberForm[i, {3, 4}]}, {i, min,
>>> max, 1/7}]
>>>
>>> Plot[Sin[x], {x, 0, 1}, Ticks -> tickFunction]
>>>
>>> You will need to read the documentation on Ticks and NumberForm to get
>>> this to do exactly what you want.
>>>
>>> Mike
>>>
>>>
>>
>> --
>> DrMajorBob@yahoo.com
>>


-- 
DrMajorBob@yahoo.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web