I have written a function Fun
as below:
Fun[x_Symbol, xrange_, imageSize_, axeslabel_] :=
Plot[x^2, {x, xrange[[1]], xrange[[2]]},
ImageSize -> imageSize,
AxesLabel -> axeslabel]
Fun[x, {-1, 2}, 400, {"x", "y"}]
However, I'd like to rewrite it to use OptionsPattern
RewriteFun[x_Symbol, OptionsPattern[Plot]] :=
Plot[x^2, {x, -1, 2},
ImageSize -> OptionValue[ImageSize],
AxesLabel -> OptionValue[AxesLabel]]
RewriteFun[x, ImageSize -> 400, AxesLabel -> {"x", "y"}]
I have two problems.
I don't know how to deal with an option like
{x, xmin, xmax}
.I don't how to get the kind of syntax coloring the varible
x
has inPlot[x^2, {x, -1, 2}]
.
So my question is: How do I revise the RewriteFun
to solve my problems?
{x, xmin, xmax}
isn't a option forPlot
. It isPlot
's required second argument. You must add a required second argument to your function to handle it. $\endgroup${x, xmin, xmax}
? $\endgroup$