Bug introduced in 12.1.0, persisting through 13.0 and fixed in 13.1


This is a documented example usage of MoleculePlot, but it returns a Graphics expression that is gray everywhere.

(* 12.2.31 *)

I confirmed that this is a bug. It occurs in certain situations. The following code produces the scene I've seen:

With[{def = Options[$FrontEnd, DefaultStyleDefinitions]},
  DownValues@Chemistry`MoleculePlot`LabelGraphics`Private`labelGraphics = Last@DownValues@Chemistry`MoleculePlot`LabelGraphics`Private`labelGraphics};
  SetOptions[$FrontEnd, DefaultStyleDefinitions->"Package.nb"];
  SetOptions[$FrontEnd, def];

2 Answers 2


This issue seems to happen when the default style definitions have a different background color. This will be fixed in an upcoming version. Either of the following should serve as a workaround:

SetOptions[Chemistry`MoleculePlot`MoleculePlot2D`Private`MoleculePlotMethod, "TextGraphics" -> False]


  ilg = Chemistry`MoleculePlot`LabelGraphics`Private`iLabelGraphics2,
  tfc = Chemistry`MoleculePlot`LabelGraphics`Private`transformFilledCurves},
  DownValues[ilg] = 
   DownValues[ilg] /. 
    tfc -> Composition[Cases[#, {__, _FilledCurve}] &, tfc];

Chemistry`MoleculePlot`LabelGraphics`Private`labelGraphics use UsingFrontEnd and ExportPacket to generate a Graphics of a string, which make the result being dependent on the front-end option Background. When it's not None, the front-end will generate a Polygon of that color, which covers the whole MoleculePlot.

It does memorization. For a correct output, we have to clean the wrong cache of it by assigning DownValues.

I'm not sure of whether it had been fixed in newer versions.

  • 1
    $\begingroup$ I had to edit the post, since the way it was written it rendered my front end not usable (Options[symbol, optionName] returns optionName -> value). I think what you have written here should be added to the question rather than as an answer. Finally, are you saying the issue only comes up when you have the stylesheet set to "Package.nb"? $\endgroup$
    – Jason B.
    Oct 19, 2021 at 16:53
  • $\begingroup$ @JasonB. Thanks for the edit. I wrote the method to replicate it in the answer because I do not know how to replicate it before being able to answer this question. I'll move it to the question to help readers replicate it eazily. $\endgroup$
    – rnotlnglgq
    Oct 20, 2021 at 4:41

Your Answer

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

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