8
$\begingroup$

I am trying to use the SphericalDensityPlot3D function that is defined here: Spherical Density Plot 3D. However, when I run all the contents of the mathematica package (".m") file, I get the following errors:

Get::noopen: Cannot open Utilities`FilterOptions.

Needs::nocont: Context Utilities`FilterOptions was not created when Needs was evaluated.

This happens when the following cell is evaluated:

Needs["Utilities`FilterOptions`"]

The last revision for this package is from 2001 and so I assume there are is some compatibility issue, since I am running version 11.2. So, does anyone know how I could fix this problem?

Thanks!

$\endgroup$

1 Answer 1

9
$\begingroup$

The FilterOptions issue has been discussed in a number of posts, you can simply modify the line

Needs["Utilities`FilterOptions`"]

to

If[$VersionNumber >= 9,
   FilterOptions[a_,b___] := Sequence @@ FilterRules[{b}, Options[a]],
   Needs["Utilities`FilterOptions`"]]

This isn't the end. Though I can't figure out what exactly they are, the package has made use of some outdated features of Graphics3D, so to get the desired result, you need to execute

<< Version5`Graphics`

first:

enter image description here

But, since you're in v11.2, why not turn to SliceDensityPlot3D? You just need to transform the coordinate first:

expr = TransformedField[ "Spherical" -> "Cartesian", 
   Re[SphericalHarmonicY[4, 2, th, ph]], {r, th, ph} -> {x, y, z}];

SliceDensityPlot3D[expr, "CenterSphere", {x, y, z} ∈ Ball[], 
 PlotLegends -> Automatic]

Mathematica graphics

BTW, for those before v10.2, I think the solutions in this post are better alternatives compared to this package.

$\endgroup$
7
  • $\begingroup$ +1, nice. I did not know about this method. I removed my hack answer. $\endgroup$
    – Nasser
    May 8, 2018 at 6:07
  • $\begingroup$ This is a great answer! Thanks! $\endgroup$
    – AG1123
    May 8, 2018 at 7:45
  • 1
    $\begingroup$ @AG1123 Thanks for accepting, but actually you don't need to accept that fast, you can wait for 24 hours or even longer to see if someone will come up with a better answer :) . $\endgroup$
    – xzczd
    May 8, 2018 at 7:53
  • $\begingroup$ I will keep that in mind in the future. :-) $\endgroup$
    – AG1123
    May 8, 2018 at 7:59
  • $\begingroup$ This fix for FilterOptions does not seem to work in version 12. Does anyone have a new fix? $\endgroup$ Feb 21, 2020 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.