Mathematica Asked on December 8, 2020
I would like to understand why I have to add First around ContourPlot in the following example to have it working:
DensityPlot[LogTQ+LogA,{LogTQ,0,4},{LogA,0,4},PlotLegends->BarLegend[Automatic],ColorFunction->"SunsetColors",Epilog->First[ContourPlot[LogA==(LogTQ)^2,{LogTQ,0,4},{LogA,0,4}]]]
I looked at the documentation of ContourPlot which says: "ContourPlot returns Graphics[GraphicsComplex[data]]"
So I guess it means that as Epilog needs to take an object of the same type as First[ContourPlot] to work.
But I find it hard to understand it from the documentation.
My questions:
In order to be more efficient with looking info on the documentation
I would like some help to see where it is written. Indeed the only
usefull info I found was that ContourPlot returns a Graphics. But
where is it explained that Epilog should eat the first element of a
Graphics. Furthermore what type is the first element of Graphics ?
Also, for instance on the Epilog documentation is written:
"is an option for graphics functions that gives a list of graphics
primitives to be rendered after the main part of the graphics is
rendered" This explain what Epilog returns, but not what it "eats". Does that actually means that Epilog must "eat" list of graphic primitives ?
If you look at the documentation for Graphics
, you'll note that there is a list of all allowed primitives given, and that those primitives go into the first argument of Graphics
(the rest is options). So if you have a graphics expression, the first element is a list of primitives, which is what Epilog
wants. The only question now is what ContourPlot
returns, and as you noted, ContourPlot
is documented to return a graphics expression (which is technically not always the case when legends are added).
Combined this means: Epilog
needs a list of graphics primitives, which are always in the first argument of a Graphics
expression, and ContourPlot
(as almost all plotting function) returns such an expression.
Answered by Lukas Lang on December 8, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP