dgaragones
(David G. Aragonés)
1
I am working on some plots and I’d like to combine in them a color gradient with different thickness for the lines.
As a simple example I have written the following code:
Plot[{4 t, 3 t, 2 t, t}, {t, 0, 3}, AxesOrigin -> {0, 0},
FrameLabel -> {"t (years)", "C (mg/l)"}, PlotTheme -> "Scientific",
PerformanceGoal -> "Quality", PlotRange -> Full,
PlotLegends ->
LineLegend[{"P", "N", "DO", "TSS"}, LegendFunction -> Frame],
PlotStyle -> "SolarColors"]
Is there any way to make the first line look thicker than the other ones combining with a color gradient like “SolarColors”?
Thank you in advance for any help!
David,
Is this what you mean?
Plot[{4 t, 3 t, 2 t, t}, {t, 0, 3}, AxesOrigin -> {0, 0},
FrameLabel -> {"t (years)", "C (mg/l)"}, PlotTheme -> "Scientific",
PerformanceGoal -> "Quality", PlotRange -> Full,
PlotLegends ->
LineLegend[{"P", "N", "DO", "TSS"}, LegendFunction -> Frame],
PlotStyle -> {Thickness[0.01], Automatic, Automatic, Automatic}]
dgaragones
(David G. Aragonés)
3
Thank your for your answer Rohit!
Yes, that’s what I meant. Just I want to combine that thickness with a gradient like “SolarColors” in the example.
I have updated the question accordingly.
Hi David,
One way to do that:
(* Color and thickness for each line *)
lineColors = ColorData["SolarColors"] /@ Rescale[{1, 2, 3, 4}]
lineWidths = {Thickness[0.01], Automatic, Automatic, Automatic}
Plot[{4 t, 3 t, 2 t, t}, {t, 0, 3}, AxesOrigin -> {0, 0},
FrameLabel -> {"t (years)", "C (mg/l)"}, PlotTheme -> "Scientific",
PerformanceGoal -> "Quality", PlotRange -> Full,
PlotLegends -> LineLegend[{"P", "N", "DO", "TSS"}, LegendFunction -> Frame],
PlotStyle -> Transpose[{lineColors, lineWidths}]]
dgaragones
(David G. Aragonés)
5
Thank you very much!
That’s exactly what I wanted!