font=18;
DensityPlot[LogTQ+LogA,{LogTQ,-2,1},{LogA,2,6},
PlotLegends->BarLegend[Automatic,
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"]
It produces:
Now let's say that I am only interested on P_C when it is bigger than 4. All things below 4 should be dark purple and the colored only be used for 4 and higher values. I thought that doing the following would do the correct output.
DensityPlot[LogTQ+LogA,{LogTQ,-2,1},{LogA,2,6},
PlotLegends->BarLegend[{"SunsetColors",{2,4}},
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"]
Unfortunately it doesnt:
The colors used on the plot are basically totally uncorrelated from the color bar. How can I fix it ?
[edit] I did what is proposed in the comment but it doesn't fix the issue:
DensityPlot[LogTQ+LogA,{LogTQ,-2,1},{LogA,2,6},
PlotLegends->BarLegend[{"SunsetColors",{2,4}},
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",ColorFunctionScaling->False]
Also, please I would like to have explanations about the command. I looked at the documentation of the ColorScaling but it is not really helpfull.
[edit2]: I tried the workaround proposed by @Ulrich Neumann. But with a slightly different function I have a weird behavior.
My code:
minColor=4*10^6;
maxColor=10^7;
ff[logTQ_,logA_]:=Max[Min[maxColor,10^(LogTQ)*10^(LogA)],minColor]
DensityPlot[ff[logTQ,logA],{LogTQ,-2,1},{LogA,2,6},
PlotLegends->BarLegend[{"SunsetColors",{minColor,maxColor}},
LegendLabel-> "Test"],
FrameLabel->{StringForm["``(``)",Subscript[log,10],Subscript[T,Q]],
StringForm["``(A)",Subscript[log,10]]} ,
PlotRange->All,ColorFunction->"SunsetColors"]
The plot:
Why is it doing this weird white line ? And how to correct it ?
Also, I would like the simplest possible solution to my problem. I think that what I want to plot is extremly standard and is typically done with a single option in many many languages. I would like to avoid to write a bunch of code for such simple ask for a plot. An adaptative solution (i.e if the colorfunction is changed the behavior keeps being correct) would also be nice.
ColorFunctionScaling -> False
$\endgroup$Exclusions -> None
, notice @UlrichNeumann has already set this in his answer. $\endgroup$