3
$\begingroup$

Bug introduced in 12.0 or earlier and persisting in 12.3.1


I've generated a Mathematica plot. When I right-click it and save it in a SVG file format like PDF or EPS, it looks great. (Unfortunately, I can't post an example, because Stack Exchange doesn't support SVG formats.) But when I save it in a raster file format like PNG, GIF, or JPEG, this weird red background appears that isn't in the plot displayed in Mathematica: enter image description here

It looks like an error notification, but it only appears in the saved graphic and not in the Mathematica notebook.

But if I copy the Mathematica plot and then paste it into a graphics editing program like Paint, the red background is gone and I can save it in a raster format through the graphics editing program: enter image description here

Any idea why this is happening, and how I can export a plot directly from Mathematica into a raster file format without needing this awkward cludge of copying and pasting into a graphics editor?

Mathematica v12.0.0.0. In case it's helpful, here's the command that I used to generate the plot from a new kernel:

Plot[{x^4, 320 x - 624, 256 (x - 4) + 256}, {x, 2, 6}, PlotStyle -> {{Thick}, {Black, Thickness -> Automatic}, {Black, Thickness -> Automatic}}, Filling -> {1 -> {{2}, LightBlue}, 1 -> {{3}, LightOrange}}, Axes -> False, Epilog -> {{PointSize[Large], Point[{4, 4^4}]}, Line[{{2, 2^4}, {4, 4^4}}], Line[{{4, 4^4}, {6, 6^4}}], Line[{{4, 4^4}, {4, 656}}]}
$\endgroup$
6
  • $\begingroup$ Export["test.png", %] $\endgroup$
    – cvgmt
    Commented Dec 5, 2021 at 1:32
  • $\begingroup$ @cvgmt Thanks, that works correctly. Any idea why manually saving as doesn't? Are you getting the same red background issue if you try? $\endgroup$
    – tparker
    Commented Dec 5, 2021 at 1:42
  • $\begingroup$ Yes, I getting the same error when I manually saving it. 12.3.1 version. $\endgroup$
    – cvgmt
    Commented Dec 5, 2021 at 1:45
  • 2
    $\begingroup$ @tparker Yes, it is a bug. Please report it to the support. Reproduced in version 12.3.1 on Windows 10 x64 when saving the plot as PNG from mouse right-click on the plot. $\endgroup$ Commented Dec 5, 2021 at 4:06
  • 2
    $\begingroup$ @AlexeyPopkov Reported to Wolfram support. $\endgroup$
    – tparker
    Commented Dec 5, 2021 at 20:00

1 Answer 1

3
$\begingroup$

It should have shown the pink box from the very beginning (which IMO is the actual bug). Thickness->Automatic is not a valid Graphics directive.

Ignoring invalid graphics directive "Thickness[Automatic]".

$\endgroup$
0

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.