8
$\begingroup$

To generate a yellow sphere, I usually write the code without using Style:

Graphics3D[{Yellow, Sphere[]}] 

However, Style seems to be a more rigorous form in many references:

Graphics3D[Style[Sphere[], Yellow]] 

I really seldom use Style even in more complex and lengthy code project. Should I or not?

Please, your suggestions and comments.

$\endgroup$
4
  • $\begingroup$ Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the help center! 3) When you see good questions and answers, vote them up by clicking the vote triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ Commented Jan 10, 2017 at 8:48
  • $\begingroup$ I think that in cases like this it does not make a difference. $\endgroup$ Commented Jan 10, 2017 at 9:58
  • $\begingroup$ I'm with Szabolcs on this. In cases like your example, it doesn't make any visible difference. General principle: if there no visible difference or measurable penalty, go with the simpler code. $\endgroup$ Commented Jan 10, 2017 at 15:13
  • $\begingroup$ @m_goldberg Thank you for editing my first post in Mathematica.SE. I also follow the rule of simplicity in general. In that reason, I seldom use Style even in more complex and lengthy code project. But, I wanted to know if I am missing something: the hidden power of Style. $\endgroup$ Commented Jan 12, 2017 at 0:53

1 Answer 1

12
$\begingroup$

In Graphics and Graphics3D Style behaves mostly as a grouping construct like List. You can use List (instead) for most things, even Options like FontSize or Antialiasing

Graphics3D[{FontSize -> 40, Text["sample"]}] 

enter image description here

Graphics[{Circle[{0, 0}, 1], {Antialiasing -> False, Circle[{0, 0}, 0.8]}}] 

enter image description here

There are however directives that only work in Style, e.g. styles defined in the style sheets:

Graphics3D[Style[Text["sample"], "Title"]] 

enter image description here

Graphics3D[Style[Text["sample"], "TI", 40]] 

enter image description here

This is not valid input:

Graphics3D[{"TI", 40, Text["sample"]}] (* bad input *) 
$\endgroup$
1
  • $\begingroup$ Thanks! I wanted to know that kind of differences. Good to know that anything defined in a Stylesheet should be included in Style instead of List. $\endgroup$ Commented Jan 12, 2017 at 1:53

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.