Message Boards Message Boards

1
|
3823 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Workaround for render differences between PlotStyle and ColorFunction?

3 Replies

Hello Clayton,

interesting propblem! With

plotb // InputForm

one sees that plotb contains a GraphicsComplex, and this seems to make the difference. If GraphicsComplex is resolved using

Normal[plotb]

then the axes look identical, but strangely the option ColorFunction -> (Black &) appears to be ignored. So if I define

plotc = Normal[plotb] /. RGBColor[__] -> Black

I cannot detect any difference between plota and plotc (at least on my system: "12.1.1 for Linux x86 (64-bit) (June 19, 2020)").

Maybe this is in a way helpful. Merry Christmas! -- Henrik

EDIT: Well, the above might not be that helpful - I basically seem to have converted plotb back to plota. But the strange thing still is the effect of GraphicsComplex.

POSTED BY: Henrik Schachner

Okay, but this doesn't really work if you actually use ColorFunction in a nontrivial way. E.g., consider:

plotd = Plot[1, {x, 0, 1}, ColorFunction -> (GrayLevel[#1] &), ImageSize -> 600]

The axes, ticks, and labels are still transformed like in plotb, and, while the Normal trick fixes that, it destroys the gradient which was the whole point of using ColorFunction to begin with.

In any case, it is helpful (at least, in an abstract way) to know that this is a GraphicsComplex issue. Indeed, upon further investigation it seems pretty clear that the issue is that GraphicsComplex has a weird effect on PlotRangePadding. For example,

Graphics[{Black, AbsoluteThickness[1.6], GraphicsComplex[{{0, 1}, {1, 1}}, Line[{{1, 2}}]]}, 
 ImageSize -> 600, Axes -> True, AspectRatio -> GoldenRatio^(-1)]

doesn't even have the right dimensions, but using the PlotRangePadding options that InputForm reveals that plota is using...

Graphics[{Black, AbsoluteThickness[1.6], GraphicsComplex[{{0, 1}, {1, 1}}, Line[{{1, 2}}]]}, 
 ImageSize -> 600, Axes -> True, AspectRatio -> GoldenRatio^(-1), 
 PlotRangePadding -> {{Scaled[0.02`], Scaled[0.02`]}, {Scaled[0.05`], Scaled[0.05`]}}]

yields an image which is identical to plota.

But, even though this seems like the underlying explanation (subject, of course, to someone who actually knows what's going on saying otherwise), I still can't figure out how to use PlotRangePadding to get plota and plotb to be identical.

When I make a figure in mathematica I always tell myself (basically) that any option that is automatic, might change in the future or be influenced somehow. You can do AbsoluteOptions on both object and inspect what changed and copy those options. You can even set them as default for Plot…

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract