Message Boards Message Boards

0
|
10760 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

[?] PlotStyle with different line thickness

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!

4 Replies
Posted 5 years ago

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}]]

enter image description here

POSTED BY: Rohit Namjoshi

Thank you very much!

That's exactly what I wanted!

Posted 5 years ago

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}]

enter image description here

POSTED BY: Rohit Namjoshi

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.

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