TransWikia.com

Color Gradient for Several Plots

Mathematica Asked on June 6, 2021

I have a Table of Sin[nx] functions where n is an integer. Now my issue is that I have been searching a way to make the plots look like a gradient of a color because if I just use the available options for PlotStyle it is hard to distinguish each plot.

Plot[Evaluate[Table[Sin[n x], {n, 1, 3, 1}]], {x, -1, 10}, AxesStyle -> {Thick, 18}, PlotStyle -> {Thick, "BlueGreenYellow"}, PlotRange -> Full]

Image

An example is shown above where I just plotted three Sin[nx]. The colors shown there are very random, I would like say a dark color red is the first plot, a lighter red is the second plot, and so on.

Another option I would like is say a gradient from red to blue, so that the evolution of the plots can be seen through the gradient of the color.

2 Answers

Your question addresses PlotTheme.

This is how default PlotTheme looks:

Plot[Evaluate[Table[BesselJ[n, x], {n, 5}]], {x, 0, 10}]

default plottheme

It is "PastelColor". No Plot without PlotTheme.

Very much contrasting is:

Plot[Evaluate[Table[BesselJ[n, x], {n, 5}]], {x, 0, 10}, 
 PlotTheme -> "GrayColor"]

GrayColor

Plot[Evaluate[Table[BesselJ[n, x], {n, 5}]], {x, 0, 10}, 
 PlotTheme -> "CoolColor"]

"CoolColor"

Like in the question the options can be overwritten and replace in putting them explicit in the options list and give them the desired value.

Your question addresses too PlotStyle. Then a solution will be

Plot[Evaluate@Table[BesselJ[n, x], {n, 3}], {x, 0, 15}, 
 PlotStyle -> {Darker@Orange, Orange, Lighter@Orange}]

PlotStyle with Orange But that there only three lightnesses built in.

Plot[Evaluate@Table[BesselJ[n, x], {n, 5}], {x, 0, 15}, 
 PlotStyle -> Table[Darker[Blue, i/5], {i, 1, 5}]]

enter image description here This in not so high in contrast but step in Darker of the color Blue. Same with Lighter:

Plot[Evaluate@Table[BesselJ[n, x], {n, 5}], {x, 0, 15}, 
 PlotStyle -> Table[Lighter[Blue, i/7.5], {i, 1, 5}]]

Lighter Mathematica knows since 12 a lot of important colors: Color.

Plot[Evaluate@Table[BesselJ[n, x], {n, 5}], {x, 0, 15}, 
 PlotStyle -> 
  Table[Lighter[Interpreter["Color"]["HTML green"], i/7.5], {i, 1, 
    5}], AxesStyle -> {Thick, 18}, PlotRange -> Full]

Interpreter["Color"]["HTML green"] You may use Blend:

Plot[Evaluate@Table[BesselJ[n, x], {n, 5}], {x, 0, 15}, 
 PlotStyle -> Table[Blend[{Red, Blue}, x], {x, 0, 1, 1/5}], 
 AxesStyle -> {Thick, 18}, PlotRange -> Full, AxesLabel -> Automatic]

Blend between Red and Blue References on Blend spend ideas for many more possibilities.

Correct answer by Steffen Jaeschke on June 6, 2021

This?

Plot[Evaluate[Table[Sin[n x], {n, 1, 3, 1}]], {x, -1, 10}, 
 AxesStyle -> {Thick, 18}, 
 PlotStyle -> (Blend[{Red, White}, #] & /@ Subdivide[0, 1, 3]), 
 PlotRange -> Full]

Answered by cvgmt on June 6, 2021

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