Use a rule variable for AxesStyle->20

  • Context: Mathematica 
  • Thread starter Thread starter Swamp Thing
  • Start date Start date
  • Tags Tags
    Variable
Click For Summary
SUMMARY

The discussion centers on using a variable rule for the AxesStyle option in the Plot function in Mathematica. The error encountered, "Options expected (instead of axs) beyond position 2 in Plot[x x,{x,0,10}, axs]," arises because the Plot function has the attribute HoldAll, preventing the variable axs from being evaluated. To resolve this issue, users must utilize Evaluate[axs] to ensure that the variable is properly evaluated as a rule. This method allows for dynamic styling of plots using variable rules.

PREREQUISITES
  • Familiarity with Mathematica's Plot function
  • Understanding of options and rules in Mathematica
  • Knowledge of the HoldAll attribute in Mathematica
  • Experience with variable evaluation in Mathematica
NEXT STEPS
  • Learn about the HoldAll attribute in Mathematica and its implications
  • Explore the use of Evaluate in Mathematica for dynamic expressions
  • Investigate advanced options handling in Mathematica's Plot function
  • Study variable rules and their applications in Mathematica
USEFUL FOR

Mathematica users, data visualizers, and anyone looking to enhance their plotting capabilities with dynamic styling options.

Swamp Thing
Insights Author
Messages
1,047
Reaction score
785
TL;DR
Why doesn't this work:
axs = AxesStyle -> 20;
Plot [ Sin[x], {x,0,10}, axs ]
How to use a variable rule, e.g. axs = AxesStyle->20 , to set the AxesStyle ? The code in the summary gives this error:

"Options expected (instead of axs) beyond position 2 in Plot[x x,{x,0,10}, axs]. An option must be a rule or a list of rules."

Isn't that "axs" a legit rule?
 
Last edited:
Physics news on Phys.org
Plot has the attribute HoldAll so axs is left unevaluated. You need to use Evaluate[axs] to force evaluation despite the HoldAll
 
  • Informative
Likes   Reactions: Swamp Thing

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 3 ·
Replies
3
Views
3K