MathGroup Archive 2009

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

Search the Archive

Re: Plotting with dotted lines solved (Re:

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104792] Re: [mg104537] Plotting with dotted lines solved (Re: [mg104341]
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Tue, 10 Nov 2009 05:59:02 -0500 (EST)
  • References: <200910280908.EAA14383@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

This makes an inferior plot to yours, but it does access the "local"  
PlotRange and AspectRatio (if I understand what that means):

DotPlot[f_, x_, xrange_, yrange_, aspratio_, npts_, ptsize_, style_,
   opts_] :=
  With[{p =
     Plot[f, {x, xrange[[1]], xrange[[2]]}, Mesh -> npts,
      MeshStyle -> Append[style, AbsolutePointSize[ptsize]],
      PlotStyle -> None,
      MeshFunctions ->
       Function[{u, v},
        Sqrt[(u/(xrange[[2]] - xrange[[1]]))^2 +
          aspratio^2 (v/(yrange[[2]] - yrange[[1]]))^2]], opts]},
   Print@AbsoluteOptions[p, {PlotRange, AspectRatio}];
   p
   ]

DotPlot[x/(1 + x), x, {0, 25}, {0, 1},
  1/GoldenRatio, 25, 5, {Blue}, {}]

{PlotRange->{{0.,25.},{0.596575,0.961538}},AspectRatio->0.618034}

I'm not sure what you planned to do with that information, however.

Bobby

On Tue, 03 Nov 2009 01:55:42 -0600, Robert Rosenbaum <robertr at math.uh.edu>  
wrote:

> I put together a way to make proper dotted plots.  Thanks to everyone
> for the help, especially to Maxim whose e-mail helped me put together
> the solution below.
>
> Just to review the issue:
> - The PlotStyle option Dotted or Dashing[{0,r}] makes small
> (rectangular) dashes as opposed to circular dots.  This appears to be
> contrary to what the help file in 7.0.1 claims.
> - Using ListPlot or using the Mesh and MeshStyle option in Plot
> produce unevenly spaced dots.
>
>
> To produce a proper dotted plot, I defined the following function:
> DotPlot[f_, x_, xrange_, yrange_, aspratio_, npts_, ptsize_, style_,
> opts_] :=
>   Plot[f, {x, xrange[[1]], xrange[[2]]}, PlotRange -> {xrange, yrange},
>     Mesh -> npts,
>    MeshStyle -> Append[style, AbsolutePointSize[ptsize]],
>    PlotStyle -> None, AspectRatio -> aspratio,
>    MeshFunctions ->
>     Function[{u, v},
>      Sqrt[( u/(xrange[[2]] - xrange[[1]]))^2 +
>        aspratio^2 (v/(yrange[[2]] - yrange[[1]]))^2]], opts]
>
>
> The arguments should be self-explanatory.  For example, try
> DotPlot[x/(1 + x), x, {0, 25}, {0, 1}, 1/GoldenRatio, 25, 5, {Blue}, {}]
>
> Now compare the plot above to:
> Plot[x/(1 + x), {x, 0, 25}, PlotStyle -> {Thick, Dotted},
>   PlotRange -> {0, 1}]
>
> or:
> ListPlot[Table[{x, x/(1 + x)}, {x, 0, 25}],
>   PlotStyle -> {Blue, AbsolutePointSize[5]}, PlotRange -> {0, 1}]
>
>
> The function DotPlot could be improved on, for example, if one could
> access PlotRange and AspectRatio inside the call to Plot (so that
> Automatic options could be used).  How would one access the local
> value of PlotRange or AspectRatio within a call to Plot?  I'm sure
> there's a way.
>
>
>
> On Oct 28, 2009, at 4:08 AM, Robert Rosenbaum wrote:
>
>> I need to plot a function with a dotted line for a figure to be
>> published.  As you may know PlotStyle->Dotted simply makes a dashed
>> line with small dashes.  Since I already have a dashed line in the
>> figure, I would prefer an actual dotted line for this function.
>>
>> I tried ListPlot with PlotMarkers set to discs, but these get spaced
>> according to the grid in the list I send to ListPlot.  In order to
>> space them equally like Dashed does, I'd have to make a non-uniform
>> grid that depends on the derivative of my function (which I don't have
>> a closed form for).
>>
>> Surely there is a reasonable way to plot with a dotted line, right?
>> Any ideas?
>>
>>
>> Best,
>> Robert
>>
>>
>>
>>
>>
>>
>
>
> Best,
> Robert
>
>
>
>
>
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: Set::setps error? Twitter.m's OOP-like approach?
  • Next by Date: Re: Ten chess-players...
  • Previous by thread: Re: Give arrow a certain color
  • Next by thread: Re: Import from web addresses fails