Re: Options in my own packages?
- To: mathgroup at smc.vnet.net
- Subject: [mg59541] Re: Options in my own packages?
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Fri, 12 Aug 2005 00:07:45 -0400 (EDT)
- Organization: Uni Leipzig
- References: <dcmv54$gqt$1@smc.vnet.net> <200508030519.BAA06314@smc.vnet.net> <ddf634$or6$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
the utility package FilterOptions is writen to
filter
options from one function to an other.
in your case
Needs["Utiltites`FilterOptions`"]
circlePlot[data_List, opts___?OptionQ] :=
Module[
...
Show[Graphics[{symbol /@ data}],
AspectRatio->aR, Axes->ax,
FilterOptions[Graphics,opts]
]
]
will pass only options that are vaild for
Graphics[] to
the Graphics[] you create.
Regards
Jens
"Curtis Osterhoudt" <gardyloo at mail.wsu.edu>
schrieb im Newsbeitrag
news:ddf634$or6$1 at smc.vnet.net...
| Hi, all,
|
| I'm writing a package which allows me to
(quickly) use common symbols
| (such as filled circles, or crosses, etc.) for
plotting data (this
| tackles the old question of defining one's own
symbols for plotting).
| Things mostly work, but I have a question about
the options available to
| me for this (and other such) package(s).
|
| Within the package is, for example, a function
called "circlePlot".
| This function takes a list of data as its
argument, and various options,
| such as the rim color of the circles, the
filling color, radii, aspect
| ratios, etc. Using a
Show[Graphics[symbol/@data]] statement, this works
| great. However, I'd also like the options
available to, for example,
| ListPlot, to be passed into the function, such
as Frame->True. I can
| explicitly account for all of these options with
new statements in the
| appropriate places (some of which go inside the
Graphics[] brackets, and
| some within the Show[] brackets). For example,
the "ax" and "aR" bits in
| the code below do what I want them to. This
explicit accounting, though,
| seems like a bit of ad-hockery to me. Is there
any semi-elegant way to
| get around this?
|
| Incidentally, I considered using ListPlot
with various Epilog->
| statements. However, there were problems with
using Scaling for the
| radii in the Circle[] and Disk[] statements, in
that the plot region was
| always limited to the {x, y} = [0..1] regions,
and I really like how, if
| one chooses a fillColor in this implementation,
successive symbols
| partially occlude the earlier symbols. That
doesn't work (as far as my
| playing has shown) with an Epilog or Prolog
statement.
|
| I'll paste the salient code below. I really
apologize if it turns
| out crappy. I tried using OutputForm, as is
always suggested, for the
| circlePlot definition, but this caused massive
problems with the 1/aR
| terms (I tried using ar^(-1) instead, but
OutputForm still put that in
| fractions, and it didn't copy-paste correctly
back into the notebook).
| This code copies correctly from this email to my
notebook; please tell
| me if it doesn't work for you.
|
| Thanks,
| Curtis O.
|
| P.S. The various Needs[] statements below aren't
in that form in the
| package, as those are taken care of in the
BeginPackage[] statement.
| However, I'll put them here in case someone
wants to experiment. I'm not
| sure if they're all really needed for this
function, but within my
| package are several other functions which do
need them. It can't hurt.
|
| Needs["Graphics`Colors`"];
|
| Needs["Graphics`MultipleListPlot`"];
|
| Needs["Graphics`Graphics`"];
|
|
| Options[circlePlot] =
|
| Flatten[Join[{radius -> 1, rimColor -> NavyBlue,
fillColor -> None,
|
| axes -> True, aspectRatio -> 0.6},
Options[ListPlot]]];
|
|
| circlePlot[data_List, opts___?OptionQ] :=
|
| With[{radius =
|
| radius
/.\[InvisibleSpace]Flatten[{opts,
Options[circlePlot]}],
|
| rimColor =
|
| rimColor
/.\[InvisibleSpace]Flatten[{opts,
Options[circlePlot]}],
|
| fillColor =
|
| fillColor
/.\[InvisibleSpace]Flatten[{opts,
Options[circlePlot]}],
|
| aR = aspectRatio
/.\[InvisibleSpace]Flatten[{opts,
Options[circlePlot]}],
|
| ax = axes
/.\[InvisibleSpace]Flatten[{opts,
Options[circlePlot]}]},
|
| symbol = If[fillColor === None,
|
| MakeSymbol[{rimColor, Thickness[0.001
radius],
|
| Circle[{0, 0}, 0.01 radius* {1,
1/aR}]}],
|
| MakeSymbol[{rimColor, Thickness[0.001
radius],
|
| Circle[{0, 0}, 0.01 radius *{1,
1/aR}], fillColor,
|
| Disk[{0, 0}, 0.008 radius *{1,
1/aR}]}]];
|
| Show[Graphics[{symbol /@ data}],
AspectRatio->aR, Axes->ax]];
|
|
|
- References:
- Re: Visualization Site Updates
- From: "Jens-Peer Kuska" <kuska@informatik.uni-leipzig.de>
- Re: Visualization Site Updates