TransWikia.com

How to know if parameters should be given to DensityPlot or to BarLegend?

Mathematica Asked on October 2, 2020

Consider the following example:

DensityPlot[10^(LogTQ)*10^(LogA),{LogTQ,-2,1},{LogA,2,6},PlotLegends->BarLegend[Automatic,LabelStyle->Directive[30],LegendLabel->"Log10[Subscript[P, C]]"],FrameTicksStyle->Directive[30],FrameLabel->{"Log10[Subscript[T, Q]]","Log10[A]"} ,LabelStyle->Directive[30],PlotRange->All,ColorFunction->"SunsetColors"]

It produces the following:

enter image description here

My question is:

Here I figured out that putting the ColorFunction as option for DensityPlot works. I also tried the following:

DensityPlot[10^(LogTQ)*10^(LogA),{LogTQ,-2,1},{LogA,2,6},PlotLegends->BarLegend["SunsetColors",LabelStyle->Directive[30],LegendLabel->"Log10[Subscript[P, C]]"],FrameTicksStyle->Directive[30],FrameLabel->{"Log10[Subscript[T, Q]]","Log10[A]"} ,LabelStyle->Directive[30],PlotRange->All]

And this time the color bar doesn’t has the same color.

My question is: How can I know to who I should pass the parameters about the legend ? I would like a general "conceptual" answer (but for a beginner please !). For instance if I want to choose a min/max value for my legend should I specify it to the DensityPlot or to the BarLegend ?

Again, I would like to understand the "philosophy" behind how it works. I am struggling with too many concept in mathematica.

One Answer

Clear["Global`*"]

font = 18;

DensityPlot[LogTQ + LogA, {LogTQ, -2, 1}, {LogA, 2, 6},
 PlotLegends -> BarLegend[{"SunsetColors", {0, 7}},
   LegendLabel -> 
    StringForm["``(``)", Subscript[log, 10], Subscript[P, C]]],
 FrameTicksStyle -> Directive[font],
 FrameLabel ->
  (StringForm["``(``)", Subscript[log, 10], #] & /@
    {Subscript[T, 
      Q], A}),
 LabelStyle -> Directive[font],
 PlotRange -> All,
 ColorFunction -> "SunsetColors"]

enter image description here

Answered by Bob Hanlon on October 2, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP