7
$\begingroup$

I believed that using Quiet, all message output would be controlled.

Quiet@Plot3D[x, {x, 1, 2}, {y, 1, a}]
Quiet@ContourPlot[x + y == 1, {x, 1, 2}, {y, 1, a}]

enter image description here enter image description here

However, this is not the case in the example above.

Is that the way it is? Or is it a bug? I am using 13.3.

Of course, if Off is used, the message output disappears.

However, in addition to Plot3D, ContourPlot and ParametricPlot3D were found in this phenomenon.

I want to effectively turn on and off these kinds of messages.

$\endgroup$
1
  • 1
    $\begingroup$ "is it a bug?" - sure looks like one to me $\endgroup$
    – Jason B.
    Commented Dec 11, 2023 at 17:19

1 Answer 1

9
$\begingroup$

It seems like Quiet works correctly at first, but then when it returns the expression, Plot3D is still there and another evaluation is attempted for some reason. See, for example:

Quiet @ With[{
    eval = Plot3D[x, {x, 1, 2}, {y, 1, a}]
},
    Hold[eval]
]

Here the returned expression is wrapped in Hold before Quiet expires, so no further evaluation can be attempted. This successfully removes all messages. So the moral of the story is that you either have to Hold the failed plot or replace it with some kind of failure object. For example:

Quiet[
 ResourceFunction["FailIfUnevaluated"] @ Plot3D[x, {x, 1, 2}, {y, 1, a}]
]

Edit

or, as pointed out by Domen in the comment below:

Quiet[Check[Plot3D[x, {x, 1, 2}, {y, 1, a}], $Failed]]
$\endgroup$
3
  • 3
    $\begingroup$ What about using Check? For example: Quiet[Check[Plot3D[x, {x, 1, 2}, {y, 1, a}], $Failed]] $\endgroup$
    – Domen
    Commented Dec 11, 2023 at 17:11
  • $\begingroup$ Oh, I understand. Thank you. $\endgroup$
    – Milk
    Commented Dec 12, 2023 at 4:15
  • $\begingroup$ Yeah, Check will work as well. Forgot about that one. $\endgroup$ Commented Dec 12, 2023 at 13:01

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.